logtest

package
v0.0.0-...-76fb5b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

Reset resets the internal buffer.

func (*DefaultTestLogBuffer) Write

func (b *DefaultTestLogBuffer) Write(p []byte) (int, error)

Write writes into 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL