Documentation ¶
Index ¶
- func NewTestContext(opts ...TestContextOpt) context.Context
- type TestContextOpt
- type TestLogEntries
- type TestLogEntry
- type TestLogger
- func (l *TestLogger) Debug(message string)
- func (l *TestLogger) Entries() []TestLogEntry
- func (l *TestLogger) EntryCount() int
- func (l *TestLogger) Error(err error, message string)
- func (l *TestLogger) Info(message string)
- func (l *TestLogger) Inject(ctx context.Context) (context.Context, func(ctx context.Context) log.Logger)
- func (l *TestLogger) LastEntry() *TestLogEntry
- func (l *TestLogger) WithDuration(key string, value time.Duration) log.Logger
- func (l *TestLogger) WithInt(key string, value int) log.Logger
- func (l *TestLogger) WithLevel(level log.Level) log.Logger
- func (l *TestLogger) WithStr(key string, value string) log.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTestContext ¶ added in v0.175.0
func NewTestContext(opts ...TestContextOpt) context.Context
NewTestContext returns a context suitable for use within unit tests. The context comes equipped with the following: 1. Logger To modify the test context further, pass additional TestContextOpt values.
Types ¶
type TestContextOpt ¶ added in v0.175.0
TestContextOpt is an interface to help configure the test context.
func WithConfig ¶ added in v0.175.0
func WithConfig(cfg *config.DefaultConfig) TestContextOpt
WithConfig returns a TestContextOpt that adds the given configuration into the test context.
func WithLogLevel ¶ added in v0.175.0
func WithLogLevel(level log.Level) TestContextOpt
WithLogLevel returns a TestContextOpt that sets the log level within the test context.
func WithLogPayload ¶ added in v0.175.0
func WithLogPayload(log bool) TestContextOpt
WithLogPayload returns a TestContextOpt that sets the configuration option within the test context to log the payload contents or not.
type TestLogEntries ¶ added in v0.175.0
type TestLogEntries struct {
Entries []TestLogEntry
}
type TestLogEntry ¶ added in v0.175.0
type TestLogger ¶ added in v0.175.0
type TestLogger struct { Level log.Level Fields map[string]interface{} // contains filtered or unexported fields }
The TestLogger is an implementation of log.Logger suitable for use within unit tests. Provision with NewTestLogger or NewTestContext.
func NewTestContextWithLogger ¶ added in v0.175.0
func NewTestContextWithLogger(opts ...TestContextOpt) (context.Context, *TestLogger)
NewTestContext returns a context (and logger) suitable for use within unit tests. The context comes equipped with the following: 1. Logger To modify the test context further, pass additional TestContextOpt values.
func NewTestLogger ¶ added in v0.175.0
func NewTestLogger() *TestLogger
func (*TestLogger) Debug ¶ added in v0.175.0
func (l *TestLogger) Debug(message string)
func (*TestLogger) Entries ¶ added in v0.175.0
func (l *TestLogger) Entries() []TestLogEntry
func (*TestLogger) EntryCount ¶ added in v0.175.0
func (l *TestLogger) EntryCount() int
func (*TestLogger) Error ¶ added in v0.175.0
func (l *TestLogger) Error(err error, message string)
func (*TestLogger) Info ¶ added in v0.175.0
func (l *TestLogger) Info(message string)
func (*TestLogger) LastEntry ¶ added in v0.175.0
func (l *TestLogger) LastEntry() *TestLogEntry
func (*TestLogger) WithDuration ¶ added in v0.175.0
func (*TestLogger) WithInt ¶ added in v0.175.0
func (l *TestLogger) WithInt(key string, value int) log.Logger