mocks

package
Version: v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package mocks contains mock implementations of various interfaces useful for writing unit-tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockMonitor

type MockMonitor struct {
	// contains filtered or unexported fields
}

MockMonitor implements runtime.Monitor for use in unit tests.

func NewMockMonitor

func NewMockMonitor(panicOnError bool) *MockMonitor

NewMockMonitor returns a Monitor that prints all messages using util.Debug() meaning that you must set environment variable DEBUG='monitor' to see the messages.

If panicOnError is set this will panic if Error() or reportError() is called. This is often useful for testing components that takes a Monitor as argument.

func (*MockMonitor) CapturePanic

func (m *MockMonitor) CapturePanic(fn func()) (incidentID string)

CapturePanic recovers from panic in fn and returns incidentID, if any

func (*MockMonitor) Count

func (m *MockMonitor) Count(name string, value float64)

Count incrments counter by name with given value

func (*MockMonitor) Debug

func (m *MockMonitor) Debug(a ...interface{})

Debug writes a debug message

func (*MockMonitor) Debugf

func (m *MockMonitor) Debugf(f string, a ...interface{})

Debugf writes debug message labelled as Debug

func (*MockMonitor) Debugln

func (m *MockMonitor) Debugln(a ...interface{})

Debugln writes a debug message

func (*MockMonitor) Error

func (m *MockMonitor) Error(a ...interface{})

Error writes debug message labelled as Error, and panics if panicOnError was set

func (*MockMonitor) Errorf

func (m *MockMonitor) Errorf(f string, a ...interface{})

Errorf writes debug message labelled as Error, and panics if panicOnError was set

func (*MockMonitor) Errorln

func (m *MockMonitor) Errorln(a ...interface{})

Errorln writes debug message labelled as Error, and panics if panicOnError was set

func (*MockMonitor) HasCounter

func (m *MockMonitor) HasCounter(name string) bool

HasCounter returns true if a counter with given name has been reported

func (*MockMonitor) HasMeasure

func (m *MockMonitor) HasMeasure(name string) bool

HasMeasure returns true if a measure with given name has been reported

func (*MockMonitor) Info

func (m *MockMonitor) Info(a ...interface{})

Info writes debug message labelled as Info

func (*MockMonitor) Infof

func (m *MockMonitor) Infof(f string, a ...interface{})

Infof writes debug message labelled as Info

func (*MockMonitor) Infoln

func (m *MockMonitor) Infoln(a ...interface{})

Infoln writes debug message labelled as Info

func (*MockMonitor) Measure

func (m *MockMonitor) Measure(name string, value ...float64)

Measure records values for given name

func (*MockMonitor) Panic

func (m *MockMonitor) Panic(a ...interface{})

Panic writes debug message labelled as Panic, and panics

func (*MockMonitor) Panicf

func (m *MockMonitor) Panicf(f string, a ...interface{})

Panicf writes debug message labelled as Panic, and panics

func (*MockMonitor) Panicln

func (m *MockMonitor) Panicln(a ...interface{})

Panicln writes debug message labelled as Panic, and panics

func (*MockMonitor) Print

func (m *MockMonitor) Print(a ...interface{})

Print writes debug message labelled as Print

func (*MockMonitor) Printf

func (m *MockMonitor) Printf(f string, a ...interface{})

Printf writes debug message labelled as Print

func (*MockMonitor) Println

func (m *MockMonitor) Println(a ...interface{})

Println writes debug message labelled as Print

func (*MockMonitor) ReportError

func (m *MockMonitor) ReportError(err error, message ...interface{}) string

ReportError records an error, and panics if panicOnError was set

func (*MockMonitor) ReportWarning

func (m *MockMonitor) ReportWarning(err error, message ...interface{}) string

ReportWarning logs a warning

func (*MockMonitor) Time

func (m *MockMonitor) Time(name string, fn func())

Time measures and records the execution time of fn

func (*MockMonitor) Warn

func (m *MockMonitor) Warn(a ...interface{})

Warn writes debug message labelled as Warn

func (*MockMonitor) Warnf

func (m *MockMonitor) Warnf(f string, a ...interface{})

Warnf writes debug message labelled as Warn

func (*MockMonitor) Warnln

func (m *MockMonitor) Warnln(a ...interface{})

Warnln writes debug message labelled as Warn

func (*MockMonitor) WithPrefix

func (m *MockMonitor) WithPrefix(prefix string) runtime.Monitor

WithPrefix creates a new child Monitor with given prefix

func (*MockMonitor) WithTag

func (m *MockMonitor) WithTag(key, value string) runtime.Monitor

WithTag creates a new child Monitor with given tag

func (*MockMonitor) WithTags

func (m *MockMonitor) WithTags(tags map[string]string) runtime.Monitor

WithTags creates a new child Monitor with given tags

Jump to

Keyboard shortcuts

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