testutil

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeThermostatService

type FakeThermostatService struct {
	S thermostat.Snapshot

	SetEnabledCalled bool
	SetEnabledArg    bool

	SetSetpointCalled bool
	SetSetpointArg    float64
	SetSetpointErr    error

	SetMinMaxCalled bool
	SetMinMaxMin    float64
	SetMinMaxMax    float64
	SetMinMaxErr    error

	SetModeCalled bool
	SetModeArg    thermostat.Mode
	SetModeErr    error

	SetFanSpeedCalled bool
	SetFanSpeedArg    thermostat.FanSpeed
	SetFanSpeedErr    error

	SetFaultCodeCalled bool
	SetFaultCodeArg    int
}

FakeThermostatService is a reusable fake implementing thermostat.Service. Put ONLY what multiple test packages need here.

func NewFakeThermostatService

func NewFakeThermostatService() *FakeThermostatService

func (*FakeThermostatService) Get

func (*FakeThermostatService) SetEnabled

func (f *FakeThermostatService) SetEnabled(b bool)

func (*FakeThermostatService) SetFanSpeed

func (f *FakeThermostatService) SetFanSpeed(fs thermostat.FanSpeed) error

func (*FakeThermostatService) SetFaultCode

func (f *FakeThermostatService) SetFaultCode(code int)

func (*FakeThermostatService) SetMinMax

func (f *FakeThermostatService) SetMinMax(min, max float64) error

func (*FakeThermostatService) SetMode

func (*FakeThermostatService) SetSetpoint

func (f *FakeThermostatService) SetSetpoint(v float64) error

type FakeWeatherProvider added in v0.9.0

type FakeWeatherProvider struct {
	Temps []float64
	Err   error

	Calls int
	// contains filtered or unexported fields
}

FakeWeatherProvider returns Temps in sequence, repeating the last one once exhausted, or Err when set. Safe for concurrent use.

func NewFakeWeatherProvider added in v0.9.0

func NewFakeWeatherProvider(temp float64) *FakeWeatherProvider

NewFakeWeatherProvider returns a provider that always reports temp.

func (*FakeWeatherProvider) CallCount added in v0.9.0

func (f *FakeWeatherProvider) CallCount() int

CallCount reads Calls under the lock, for use while the provider runs concurrently.

func (*FakeWeatherProvider) OutdoorTemperature added in v0.9.0

func (f *FakeWeatherProvider) OutdoorTemperature(context.Context) (float64, error)

OutdoorTemperature returns the next temperature in the sequence, or Err if set.

Jump to

Keyboard shortcuts

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