Documentation ¶
Index ¶
- func HighlightErrorOutput(te *GoTestEvent, _ *TestLogModifierConfig) error
- func JsonTestOutputToStandard(te *GoTestEvent, c *TestLogModifierConfig) error
- func ReadAndModifyLogs(ctx context.Context, r io.Reader, modifiers []TestLogModifier, ...) error
- func RemoveTestLogPrefix(te *GoTestEvent, _ *TestLogModifierConfig) error
- func SliceContains[T comparable](slice []T, item T) bool
- func StartGroupFail(title string, c *TestLogModifierConfig, hasLogs bool)
- func StartGroupPass(title string, c *TestLogModifierConfig, hasLogs bool)
- func StartGroupSkip(title string, c *TestLogModifierConfig, hasLogs bool)
- type Action
- type GoTestEvent
- type Test
- type TestLogModifier
- type TestLogModifierConfig
- type TestPackage
- type TestPackageMap
- type TestStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HighlightErrorOutput ¶
func HighlightErrorOutput(te *GoTestEvent, _ *TestLogModifierConfig) error
func JsonTestOutputToStandard ¶
func JsonTestOutputToStandard(te *GoTestEvent, c *TestLogModifierConfig) error
JsonTestOutputToStandard is a TestLogModifier that takes a GoTestEvent and modifies the output as configured
func ReadAndModifyLogs ¶
func ReadAndModifyLogs(ctx context.Context, r io.Reader, modifiers []TestLogModifier, c *TestLogModifierConfig) error
func RemoveTestLogPrefix ¶
func RemoveTestLogPrefix(te *GoTestEvent, _ *TestLogModifierConfig) error
RemoveTestLogPrefix is a TestLogModifier that takes a GoTestEvent and removes the test log prefix
func SliceContains ¶
func SliceContains[T comparable](slice []T, item T) bool
SliceContains checks if a slice contains a given item
func StartGroupFail ¶
func StartGroupFail(title string, c *TestLogModifierConfig, hasLogs bool)
StartGroupFail starts a group in the CI environment with a red title
func StartGroupPass ¶
func StartGroupPass(title string, c *TestLogModifierConfig, hasLogs bool)
StartGroupPass starts a group in the CI environment with a green title
func StartGroupSkip ¶
func StartGroupSkip(title string, c *TestLogModifierConfig, hasLogs bool)
StartGroupSkip starts a group in the CI environment with a green title
Types ¶
type GoTestEvent ¶
type GoTestEvent struct { Time time.Time `json:"Time,omitempty"` Action Action `json:"Action,omitempty"` Package string `json:"Package,omitempty"` Test string `json:"Test,omitempty"` Output string `json:"Output,omitempty"` Elapsed float64 `json:"Elapsed,omitempty"` }
Representation of a go test -json event
func ParseTestEvent ¶
func ParseTestEvent(b []byte) (*GoTestEvent, error)
parseTestEvent parses a byte slice into a TestEvent
func (GoTestEvent) Print ¶
func (gte GoTestEvent) Print()
Print prints the GoTestEvent to the console
func (GoTestEvent) String ¶
func (gte GoTestEvent) String() (string, error)
String returns the JSON string representation of the GoTestEvent
type Test ¶
type Test struct { Name string Logs []GoTestEvent Status TestStatus Complete bool HasPanic bool Elapsed float64 }
type Test []GoTestEvent
func (*Test) Print ¶
func (t *Test) Print(c *TestLogModifierConfig)
Print prints the Test to the console
type TestLogModifier ¶
type TestLogModifier func(*GoTestEvent, *TestLogModifierConfig) error
TestLogModifier is a generic function interface that modifies a GoTestEvent
func SetupModifiers ¶
func SetupModifiers(c *TestLogModifierConfig) []TestLogModifier
SetupModifiers sets up the modifiers based on the flags provided
type TestLogModifierConfig ¶
type TestLogModifierConfig struct { IsJsonInput *bool RemoveTLogPrefix *bool HidePassingTests *clihelper.BoolFlag HidePassingLogs *bool OnlyErrors *clihelper.BoolFlag Color *bool CI *bool SinglePackage *bool ShouldImmediatelyPrint bool TestPackageMap TestPackageMap FailuresExist bool ErrorAtTopLength *int }
func NewDefaultConfig ¶
func NewDefaultConfig() *TestLogModifierConfig
func (*TestLogModifierConfig) Validate ¶
func (c *TestLogModifierConfig) Validate() error
ValidateConfig validates the TestLogModifierConfig does not have any invalid combinations
type TestPackage ¶
type TestPackage struct { Name string NonTestLogs []GoTestEvent Tests map[string]*Test TestOrder []string Failed bool Elapsed float64 Message string }
func (*TestPackage) AddTestEvent ¶
func (p *TestPackage) AddTestEvent(te *GoTestEvent) *Test
func (*TestPackage) Print ¶
func (p *TestPackage) Print(c *TestLogModifierConfig)
Print prints the TestPackage to the console
func (TestPackage) ShouldPrintTest ¶
func (p TestPackage) ShouldPrintTest(test Test, c *TestLogModifierConfig) bool
type TestPackageMap ¶
type TestPackageMap map[string]*TestPackage
func (TestPackageMap) InitPackageInMap ¶
func (m TestPackageMap) InitPackageInMap(packageName string)
type TestStatus ¶ added in v1.0.5
type TestStatus string
const ( TestStatusPass TestStatus = TestStatus(ActionPass) TestStatusFail TestStatus = TestStatus(ActionFail) TestStatusSkip TestStatus = TestStatus(ActionSkip) )