Documentation ¶
Index ¶
- func AssertContainLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, ...) bool
- func AssertContainNotLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, ...) bool
- func AssertHasLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, ...) bool
- func AssertHasNotLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, ...) bool
- type DefaultTestLogBuffer
- func (b *DefaultTestLogBuffer) Buffer() *bytes.Buffer
- func (b *DefaultTestLogBuffer) ContainRecord(expectedAttributes map[string]interface{}) (bool, error)
- func (b *DefaultTestLogBuffer) HasRecord(expectedAttributes map[string]interface{}) (bool, error)
- func (b *DefaultTestLogBuffer) Records() ([]*TestLogRecord, error)
- func (b *DefaultTestLogBuffer) Reset() TestLogBuffer
- func (b *DefaultTestLogBuffer) Write(p []byte) (int, error)
- type TestLogBuffer
- type TestLogRecord
- func (r *TestLogRecord) Attribute(name string) (interface{}, error)
- func (r *TestLogRecord) ContainAttributes(expectedAttributes map[string]interface{}) bool
- func (r *TestLogRecord) Level() (string, error)
- func (r *TestLogRecord) MatchAttributes(expectedAttributes map[string]interface{}) bool
- func (r *TestLogRecord) Message() (string, error)
- func (r *TestLogRecord) Service() (string, error)
- func (r *TestLogRecord) Time() (time.Time, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContainLogRecord ¶
func AssertContainLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, expectedAttributes map[string]interface{}) bool
AssertContainLogRecord allows to assert if a log record partially matching provided attributes can be found.
func AssertContainNotLogRecord ¶
func AssertContainNotLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, expectedAttributes map[string]interface{}) bool
AssertContainNotLogRecord allows to assert if a log record partially matching provided attributes cannot be found.
func AssertHasLogRecord ¶
func AssertHasLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, expectedAttributes map[string]interface{}) bool
AssertHasLogRecord allows to assert if a log record exactly matching provided attributes can be found.
func AssertHasNotLogRecord ¶
func AssertHasNotLogRecord(tb testing.TB, testLogBuffer TestLogBuffer, expectedAttributes map[string]interface{}) bool
AssertHasNotLogRecord allows to assert if a log record exactly matching provided attributes cannot be found.
Types ¶
type DefaultTestLogBuffer ¶
type DefaultTestLogBuffer struct {
// contains filtered or unexported fields
}
DefaultTestLogBuffer is the default TestLogBuffer implementation.
func (*DefaultTestLogBuffer) Buffer ¶
func (b *DefaultTestLogBuffer) Buffer() *bytes.Buffer
Buffer returns the internal buffer.
func (*DefaultTestLogBuffer) ContainRecord ¶
func (b *DefaultTestLogBuffer) ContainRecord(expectedAttributes map[string]interface{}) (bool, error)
ContainRecord return true if a log record from the internal buffer is partially matching provided attributes.
func (*DefaultTestLogBuffer) HasRecord ¶
func (b *DefaultTestLogBuffer) HasRecord(expectedAttributes map[string]interface{}) (bool, error)
HasRecord return true if a log record from the internal buffer is exactly matching provided attributes.
func (*DefaultTestLogBuffer) Records ¶
func (b *DefaultTestLogBuffer) Records() ([]*TestLogRecord, error)
Records return the list of TestLogRecord from the internal buffer.
func (*DefaultTestLogBuffer) Reset ¶
func (b *DefaultTestLogBuffer) Reset() TestLogBuffer
Reset resets the internal buffer.
type TestLogBuffer ¶
type TestLogBuffer interface { io.Writer Buffer() *bytes.Buffer Reset() TestLogBuffer Records() ([]*TestLogRecord, error) HasRecord(expectedAttributes map[string]interface{}) (bool, error) ContainRecord(expectedAttributes map[string]interface{}) (bool, error) }
TestLogBuffer is the interface for test log buffers.
func NewDefaultTestLogBuffer ¶
func NewDefaultTestLogBuffer() TestLogBuffer
NewDefaultTestLogBuffer returns a DefaultTestLogBuffer, implementing TestLogBuffer.
type TestLogRecord ¶
type TestLogRecord struct {
// contains filtered or unexported fields
}
TestLogRecord is a test log record, composed of attributes.
func NewTestLogRecord ¶
func NewTestLogRecord(attributes map[string]interface{}) *TestLogRecord
NewTestLogRecord returns a TestLogRecord.
func (*TestLogRecord) Attribute ¶
func (r *TestLogRecord) Attribute(name string) (interface{}, error)
Attribute returns an attribute of the TestLogRecord by name.
func (*TestLogRecord) ContainAttributes ¶
func (r *TestLogRecord) ContainAttributes(expectedAttributes map[string]interface{}) bool
ContainAttributes returns true if the TestLogRecord partially matches provided attributes.
func (*TestLogRecord) Level ¶
func (r *TestLogRecord) Level() (string, error)
Level returns the level of the TestLogRecord.
func (*TestLogRecord) MatchAttributes ¶
func (r *TestLogRecord) MatchAttributes(expectedAttributes map[string]interface{}) bool
MatchAttributes returns true if the TestLogRecord exactly matches provided attributes.
func (*TestLogRecord) Message ¶
func (r *TestLogRecord) Message() (string, error)
Message returns the message of the TestLogRecord.
func (*TestLogRecord) Service ¶
func (r *TestLogRecord) Service() (string, error)
Service returns the service name of the TestLogRecord.
func (*TestLogRecord) Time ¶
func (r *TestLogRecord) Time() (time.Time, error)
Time returns the time of the TestLogRecord.