Documentation ¶
Index ¶
- type TransportTest
- func (tt *TransportTest) AssertLogsContainString(strs ...string)
- func (tt *TransportTest) AssertLogsDoesntContainString(s string)
- func (tt *TransportTest) AssertMessagesByLogLevel(level uclog.LogLevel, expected int, opts ...assert.Option)
- func (tt *TransportTest) ClearEvents()
- func (tt *TransportTest) ClearMessages()
- func (tt *TransportTest) Close()
- func (tt *TransportTest) Flush() error
- func (tt *TransportTest) GetEventsLoggedByName(name string) []uclog.LogEvent
- func (tt *TransportTest) GetName() string
- func (tt *TransportTest) GetStats() uclog.LogTransportStats
- func (tt *TransportTest) Init() (*uclog.TransportConfig, error)
- func (tt *TransportTest) Write(ctx context.Context, event uclog.LogEvent)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TransportTest ¶
type TransportTest struct { Events []testLogRecord LogMessages map[uclog.LogLevel][]string // contains filtered or unexported fields }
TransportTest is a test log transport
func InitLoggerAndTransportsForTests ¶
func InitLoggerAndTransportsForTests(t *testing.T) *TransportTest
InitLoggerAndTransportsForTests configures logging to use golang test logging TODO: once we simplify log config & init, this can get unified through the main Init() path, but I don't want to introduce yet another config fork for this TODO: is there a way to do this more automatically than per-test? TestMain doesn't have testing.T or .B TODO: the fact that this returns a *bytes.Buffer representing the log is pretty icky
func InitLoggerAndTransportsForTestsWithLevel ¶ added in v0.8.5
func InitLoggerAndTransportsForTestsWithLevel(t *testing.T, logLevel uclog.LogLevel) *TransportTest
InitLoggerAndTransportsForTestsWithLevel configures logging to use golang test logging with a specific log level
func (*TransportTest) AssertLogsContainString ¶ added in v1.1.0
func (tt *TransportTest) AssertLogsContainString(strs ...string)
AssertLogsContainString asserts that at least one log message contains a one of the strings passed to this function
func (*TransportTest) AssertLogsDoesntContainString ¶ added in v1.1.0
func (tt *TransportTest) AssertLogsDoesntContainString(s string)
AssertLogsDoesntContainString asserts that no log message contains a particular string
func (*TransportTest) AssertMessagesByLogLevel ¶ added in v0.8.3
func (tt *TransportTest) AssertMessagesByLogLevel(level uclog.LogLevel, expected int, opts ...assert.Option)
AssertMessagesByLogLevel asserts that the number of messages logged at a particular level is as expected
func (*TransportTest) ClearEvents ¶
func (tt *TransportTest) ClearEvents()
ClearEvents clears all logged events
func (*TransportTest) ClearMessages ¶ added in v0.8.5
func (tt *TransportTest) ClearMessages()
ClearMessages clears all logged messages
func (*TransportTest) Close ¶
func (tt *TransportTest) Close()
Close prevents writing to the transport after a test ends see https://github.com/golang/go/issues/40343
func (*TransportTest) GetEventsLoggedByName ¶
func (tt *TransportTest) GetEventsLoggedByName(name string) []uclog.LogEvent
GetEventsLoggedByName checks if a particular event has been logged
func (*TransportTest) GetName ¶
func (tt *TransportTest) GetName() string
GetName returns transport name
func (*TransportTest) GetStats ¶
func (tt *TransportTest) GetStats() uclog.LogTransportStats
GetStats returns stats
func (*TransportTest) Init ¶
func (tt *TransportTest) Init() (*uclog.TransportConfig, error)
Init initializes the test transport