mock

package
v0.0.0-...-bfe5d0e Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAirMonitor

func NewAirMonitor[V data.ValueType](tb testing.TB, opts ...MockAirMonitorOption) air.AirMonitor

func NewColour

func NewColour(tb testing.TB, opts ...MockColouredOption) light.Colour

func NewDimmer

func NewDimmer(tb testing.TB, opts ...MockDimmerOption) light.Dimmer

func NewFan

func NewFan(tb testing.TB, opts ...MockFanOption) air.Fan

func NewHeater

func NewHeater[V data.ValueType](tb testing.TB, opts ...MockHeaterOption[V]) air.Heater[V]

func NewLight

func NewLight(tb testing.TB, opts ...MockLightOption) light.Light

func NewMonitor

func NewMonitor(tb testing.TB, opts ...MockMonitorOption) outlet.Monitor

func NewOutlet

func NewOutlet(tb testing.TB, opts ...MockOutletOption) outlet.Outlet

Types

type MethodCallOption

type MethodCallOption func(call *mock.Call)

MethodCallOption allows to extend the assertion of the method

func WithMethodPanic

func WithMethodPanic(message string) MethodCallOption

func WithMethodTimes

func WithMethodTimes(count int) MethodCallOption

func WithMethodVirtualWait

func WithMethodVirtualWait(clk clock.Clock, d time.Duration) MethodCallOption

type MockAirMonitor

type MockAirMonitor struct {
	air.EmbedableAirMonitor
	MockMonitoredDevice
}

type MockAirMonitorOption

type MockAirMonitorOption func(mam *MockAirMonitor)

type MockColour

type MockColour struct {
	MockLight
}

func (*MockColour) SetColour

func (mc *MockColour) SetColour(ctx context.Context, c color.Color) error

type MockColouredOption

type MockColouredOption func(mc *MockColour)

func WithColourAssertSetColour

func WithColourAssertSetColour(ctx context.Context, c color.Color, err error, opts ...MethodCallOption) MockColouredOption

func WithColourDeviceOptions

func WithColourDeviceOptions(opts ...MockDeviceOption) MockColouredOption

type MockDevice

type MockDevice struct {
	mock.Mock
}

MockDevice implements all the methods that a potential device can be. Using this mock, you must use the highest order value otherwise, you could potentially cast to the wrong type

func NewDevice

func NewDevice(tb testing.TB, opts ...MockDeviceOption) *MockDevice

func (*MockDevice) GetInformation

func (md *MockDevice) GetInformation(ctx context.Context) (*device.Information, error)

func (*MockDevice) Heartbeat

func (md *MockDevice) Heartbeat(context.Context) (device.State, error)

func (*MockDevice) Power

func (md *MockDevice) Power(ctx context.Context, on bool) error

type MockDeviceOption

type MockDeviceOption func(md *MockDevice)

func WithAsserDeviceGetInformation

func WithAsserDeviceGetInformation(ctx context.Context, info *device.Information, err error, opts ...MethodCallOption) MockDeviceOption

func WithAssertDeviceHeartbeat

func WithAssertDeviceHeartbeat(ctx context.Context, state device.State, err error, opts ...MethodCallOption) MockDeviceOption

func WithAssertDevicePower

func WithAssertDevicePower(ctx context.Context, on bool, err error, opts ...MethodCallOption) MockDeviceOption

type MockDimmer

type MockDimmer struct {
	MockLight
}

func (*MockDimmer) SetBrightness

func (md *MockDimmer) SetBrightness(ctx context.Context, percentage float64) error

type MockDimmerOption

type MockDimmerOption func(md *MockDimmer)

func WithDimmerDeviceOptions

func WithDimmerDeviceOptions(opts ...MockDeviceOption) MockDimmerOption

func WithLightAssertSetBrightness

func WithLightAssertSetBrightness(ctx context.Context, percentage float64, err error, opts ...MethodCallOption) MockDimmerOption

type MockFan

type MockFan struct {
	MockDevice
}

func (*MockFan) SetSpeed

func (mf *MockFan) SetSpeed(ctx context.Context, speed float64) error

type MockFanOption

type MockFanOption func(mf *MockFan)

func WithAssertFanSetSpeed

func WithAssertFanSetSpeed(ctx context.Context, speed float64, err error, opts ...MethodCallOption) MockFanOption

func WithFanDeviceOptions

func WithFanDeviceOptions(opts ...MockDeviceOption) MockFanOption

type MockHeater

type MockHeater[V data.ValueType] struct {
	MockFan
}

func (*MockHeater[V]) SetTemperature

func (mh *MockHeater[V]) SetTemperature(ctx context.Context, temp data.Value[V]) error

type MockHeaterOption

type MockHeaterOption[V data.ValueType] func(mh *MockHeater[V])

func WithAssertHeaterSetTemperature

func WithAssertHeaterSetTemperature[V data.ValueType](ctx context.Context, temp data.Value[V], err error, opts ...MethodCallOption) MockHeaterOption[V]

func WithHeaterFanOptions

func WithHeaterFanOptions[V data.ValueType](opts ...MockFanOption) MockHeaterOption[V]

type MockLight

type MockLight struct {
	MockDevice
	light.EmbedableLight
}

type MockLightOption

type MockLightOption func(ml *MockLight)

func WithLightDeviceOptions

func WithLightDeviceOptions(opts ...MockLightOption) MockLightOption

type MockMonitor

type MockMonitor struct {
	MockMonitoredDevice
	outlet.EmbedableMonitor
}

type MockMonitorOption

type MockMonitorOption func(mo *MockMonitor)

func WithMonitorDeviceOptions

func WithMonitorDeviceOptions(opts ...MockMonitoredDeviceOption) MockMonitorOption

type MockMonitoredDevice

type MockMonitoredDevice struct {
	MockDevice
}

MockMonitoredDevice embeds the MockDevice an implements the method GetStatistics Please refere to MockDevice's warning

func NewMonitoredDevice

func NewMonitoredDevice(tb testing.TB, opts ...MockMonitoredDeviceOption) *MockMonitoredDevice

func (*MockMonitoredDevice) GetStatistics

func (md *MockMonitoredDevice) GetStatistics(ctx context.Context) ([]data.Statistic, error)

type MockMonitoredDeviceOption

type MockMonitoredDeviceOption func(md *MockMonitoredDevice)

func WithAssertMonitoredDeviceGetStatstics

func WithAssertMonitoredDeviceGetStatstics(ctx context.Context, stats []data.Statistic, err error, opts ...MethodCallOption) MockMonitoredDeviceOption

func WithMonitoredDeviceOptions

func WithMonitoredDeviceOptions(opts ...MockDeviceOption) MockMonitoredDeviceOption

type MockOutlet

type MockOutlet struct {
	MockDevice
	outlet.EmbedableOutlet
}

type MockOutletOption

type MockOutletOption func(mo *MockOutlet)

func WithOutletDeviceOptions

func WithOutletDeviceOptions(opts ...MockDeviceOption) MockOutletOption

Jump to

Keyboard shortcuts

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