test

package
v0.10.2-v0-10-x-lts.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TempLogFileName added in v0.10.1

func TempLogFileName(t *testing.T, suffix string) string

TempLogFileName returns a filename for a log file that is unique to the test.

Types

type FileLogger added in v0.10.1

type FileLogger struct {
	T *testing.T
	// contains filtered or unexported fields
}

FileLogger is a simple, thread-safe logger that logs to a tempFile and is intended for use in testing.

func NewFileLogger added in v0.10.1

func NewFileLogger(t *testing.T) *FileLogger

NewLogger create a Logger using the name of the test as the filename.

func NewFileLoggerCustom added in v0.10.1

func NewFileLoggerCustom(t *testing.T, fileName string) *FileLogger

NewLoggerCustom create a Logger using the given filename.

func (*FileLogger) Debug added in v0.10.1

func (f *FileLogger) Debug(msg string, keyvals ...interface{})

Debug prints a debug message.

func (*FileLogger) Error added in v0.10.1

func (f *FileLogger) Error(msg string, keyvals ...interface{})

Error prints an error message.

func (*FileLogger) Info added in v0.10.1

func (f *FileLogger) Info(msg string, keyvals ...interface{})

Info prints an info message.

func (*FileLogger) With added in v0.10.1

func (f *FileLogger) With(keyvals ...interface{}) log.Logger

With returns a new Logger with the given keyvals added.

type Logger

type Logger struct {
	T *testing.T
	// contains filtered or unexported fields
}

Logger is a simple, yet thread-safe, logger intended for use in unit tests.

func NewLogger

func NewLogger(t *testing.T) *Logger

NewLogger create a Logger that outputs data using given testing.T instance.

func (*Logger) Debug

func (t *Logger) Debug(msg string, keyvals ...interface{})

Debug prints a debug message.

func (*Logger) Error

func (t *Logger) Error(msg string, keyvals ...interface{})

Error prints an error message.

func (*Logger) Info

func (t *Logger) Info(msg string, keyvals ...interface{})

Info prints an info message.

type MockLogger

type MockLogger struct {
	DebugLines, InfoLines, ErrLines []string
}

MockLogger is a fake logger that accumulates all the inputs.

It can be used in tests to ensure that certain messages was logged with correct severity.

func (*MockLogger) Debug

func (t *MockLogger) Debug(msg string, keyvals ...interface{})

Debug saves a debug message.

func (*MockLogger) Error

func (t *MockLogger) Error(msg string, keyvals ...interface{})

Error saves an error message.

func (*MockLogger) Info

func (t *MockLogger) Info(msg string, keyvals ...interface{})

Info saves an info message.

Jump to

Keyboard shortcuts

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