apex

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 5 Imported by: 0

README

apex mocks

GoReportCard GoDoc Build Statuscoverage report

Package mocks provides a mock implementation of Apex which can be used to unit test applications using Apex logging.

Download
go get gitlab.com/unboundsoftware/apex-mocks
Usage

Make sure that your application uses log.Interface to be able to pass in a Mock from your tests instead.

To verify what has been logged:

  logger := &apex.Mock{}
  // ... run your actual test using the logger above
  logger.Check(t, tt.wantLogged)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock struct {
	*sync.RWMutex
	log.Interface
	Logged []string
}

Mock has a Logger for use in unit-testing

func New added in v0.0.3

func New() *Mock

New instantiates a new Mock and sets the log.Handler to it

func (*Mock) Check

func (m *Mock) Check(t testing.TB, wantLogged []string)

Check verifies that the application has logged the expected strings

func (*Mock) HandleLog added in v0.0.3

func (m *Mock) HandleLog(entry *log.Entry) error

HandleLog stores the logged entries to be able to check them later

Jump to

Keyboard shortcuts

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