Documentation ¶
Index ¶
- Constants
- func BatteryLevelChangedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
- func DeviceNotObservedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
- func DeviceStatusHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
- func FunctionUpdatedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
- type AlarmConfig
- type AlarmService
- type AlarmServiceMock
- func (mock *AlarmServiceMock) AddAlarm(ctx context.Context, alarm db.Alarm) error
- func (mock *AlarmServiceMock) AddAlarmCalls() []struct{ ... }
- func (mock *AlarmServiceMock) CloseAlarm(ctx context.Context, alarmID int) error
- func (mock *AlarmServiceMock) CloseAlarmCalls() []struct{ ... }
- func (mock *AlarmServiceMock) GetAlarms(ctx context.Context, tenants ...string) ([]db.Alarm, error)
- func (mock *AlarmServiceMock) GetAlarmsByID(ctx context.Context, id int) (db.Alarm, error)
- func (mock *AlarmServiceMock) GetAlarmsByIDCalls() []struct{ ... }
- func (mock *AlarmServiceMock) GetAlarmsByRefID(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error)
- func (mock *AlarmServiceMock) GetAlarmsByRefIDCalls() []struct{ ... }
- func (mock *AlarmServiceMock) GetAlarmsCalls() []struct{ ... }
- func (mock *AlarmServiceMock) GetConfiguration() Configuration
- func (mock *AlarmServiceMock) GetConfigurationCalls() []struct{}
- func (mock *AlarmServiceMock) Start()
- func (mock *AlarmServiceMock) StartCalls() []struct{}
- func (mock *AlarmServiceMock) Stop()
- func (mock *AlarmServiceMock) StopCalls() []struct{}
- type Configuration
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func BatteryLevelChangedHandler ¶
func BatteryLevelChangedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
func DeviceNotObservedHandler ¶
func DeviceNotObservedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
func DeviceStatusHandler ¶
func DeviceStatusHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
func FunctionUpdatedHandler ¶
func FunctionUpdatedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler
Types ¶
type AlarmConfig ¶
type AlarmService ¶
type AlarmService interface { Start() Stop() GetAlarms(ctx context.Context, tenants ...string) ([]db.Alarm, error) GetAlarmsByID(ctx context.Context, id int) (db.Alarm, error) GetAlarmsByRefID(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error) AddAlarm(ctx context.Context, alarm db.Alarm) error CloseAlarm(ctx context.Context, alarmID int) error GetConfiguration() Configuration }
func New ¶
func New(d db.AlarmRepository, m messaging.MsgContext, cfg *Configuration) AlarmService
type AlarmServiceMock ¶
type AlarmServiceMock struct { // AddAlarmFunc mocks the AddAlarm method. AddAlarmFunc func(ctx context.Context, alarm db.Alarm) error // CloseAlarmFunc mocks the CloseAlarm method. CloseAlarmFunc func(ctx context.Context, alarmID int) error // GetAlarmsFunc mocks the GetAlarms method. GetAlarmsFunc func(ctx context.Context, tenants ...string) ([]db.Alarm, error) // GetAlarmsByIDFunc mocks the GetAlarmsByID method. GetAlarmsByIDFunc func(ctx context.Context, id int) (db.Alarm, error) // GetAlarmsByRefIDFunc mocks the GetAlarmsByRefID method. GetAlarmsByRefIDFunc func(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error) // GetConfigurationFunc mocks the GetConfiguration method. GetConfigurationFunc func() Configuration // StartFunc mocks the Start method. StartFunc func() // StopFunc mocks the Stop method. StopFunc func() // contains filtered or unexported fields }
AlarmServiceMock is a mock implementation of AlarmService.
func TestSomethingThatUsesAlarmService(t *testing.T) { // make and configure a mocked AlarmService mockedAlarmService := &AlarmServiceMock{ AddAlarmFunc: func(ctx context.Context, alarm db.Alarm) error { panic("mock out the AddAlarm method") }, CloseAlarmFunc: func(ctx context.Context, alarmID int) error { panic("mock out the CloseAlarm method") }, GetAlarmsFunc: func(ctx context.Context, tenants ...string) ([]db.Alarm, error) { panic("mock out the GetAlarms method") }, GetAlarmsByIDFunc: func(ctx context.Context, id int) (db.Alarm, error) { panic("mock out the GetAlarmsByID method") }, GetAlarmsByRefIDFunc: func(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error) { panic("mock out the GetAlarmsByRefID method") }, GetConfigurationFunc: func() Configuration { panic("mock out the GetConfiguration method") }, StartFunc: func() { panic("mock out the Start method") }, StopFunc: func() { panic("mock out the Stop method") }, } // use mockedAlarmService in code that requires AlarmService // and then make assertions. }
func (*AlarmServiceMock) AddAlarmCalls ¶
func (mock *AlarmServiceMock) AddAlarmCalls() []struct { Ctx context.Context Alarm db.Alarm }
AddAlarmCalls gets all the calls that were made to AddAlarm. Check the length with:
len(mockedAlarmService.AddAlarmCalls())
func (*AlarmServiceMock) CloseAlarm ¶
func (mock *AlarmServiceMock) CloseAlarm(ctx context.Context, alarmID int) error
CloseAlarm calls CloseAlarmFunc.
func (*AlarmServiceMock) CloseAlarmCalls ¶
func (mock *AlarmServiceMock) CloseAlarmCalls() []struct { Ctx context.Context AlarmID int }
CloseAlarmCalls gets all the calls that were made to CloseAlarm. Check the length with:
len(mockedAlarmService.CloseAlarmCalls())
func (*AlarmServiceMock) GetAlarmsByID ¶
GetAlarmsByID calls GetAlarmsByIDFunc.
func (*AlarmServiceMock) GetAlarmsByIDCalls ¶
func (mock *AlarmServiceMock) GetAlarmsByIDCalls() []struct { Ctx context.Context ID int }
GetAlarmsByIDCalls gets all the calls that were made to GetAlarmsByID. Check the length with:
len(mockedAlarmService.GetAlarmsByIDCalls())
func (*AlarmServiceMock) GetAlarmsByRefID ¶
func (mock *AlarmServiceMock) GetAlarmsByRefID(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error)
GetAlarmsByRefID calls GetAlarmsByRefIDFunc.
func (*AlarmServiceMock) GetAlarmsByRefIDCalls ¶
func (mock *AlarmServiceMock) GetAlarmsByRefIDCalls() []struct { Ctx context.Context RefID string Tenants []string }
GetAlarmsByRefIDCalls gets all the calls that were made to GetAlarmsByRefID. Check the length with:
len(mockedAlarmService.GetAlarmsByRefIDCalls())
func (*AlarmServiceMock) GetAlarmsCalls ¶
func (mock *AlarmServiceMock) GetAlarmsCalls() []struct { Ctx context.Context Tenants []string }
GetAlarmsCalls gets all the calls that were made to GetAlarms. Check the length with:
len(mockedAlarmService.GetAlarmsCalls())
func (*AlarmServiceMock) GetConfiguration ¶
func (mock *AlarmServiceMock) GetConfiguration() Configuration
GetConfiguration calls GetConfigurationFunc.
func (*AlarmServiceMock) GetConfigurationCalls ¶
func (mock *AlarmServiceMock) GetConfigurationCalls() []struct { }
GetConfigurationCalls gets all the calls that were made to GetConfiguration. Check the length with:
len(mockedAlarmService.GetConfigurationCalls())
func (*AlarmServiceMock) StartCalls ¶
func (mock *AlarmServiceMock) StartCalls() []struct { }
StartCalls gets all the calls that were made to Start. Check the length with:
len(mockedAlarmService.StartCalls())
func (*AlarmServiceMock) StopCalls ¶
func (mock *AlarmServiceMock) StopCalls() []struct { }
StopCalls gets all the calls that were made to Stop. Check the length with:
len(mockedAlarmService.StopCalls())
type Configuration ¶
type Configuration struct {
AlarmConfigurations []AlarmConfig
}
func LoadConfiguration ¶
func LoadConfiguration(configFile string) *Configuration