Documentation
¶
Index ¶
- Constants
- type App
- type AppMock
- func (mock *AppMock) GetDevice(ctx context.Context, deviceID string) (dmc.Device, error)
- func (mock *AppMock) GetDeviceCalls() []struct{ ... }
- func (mock *AppMock) GetMeasurements(ctx context.Context, deviceID string, temprel string, t time.Time, ...) ([]application.Measurement, error)
- func (mock *AppMock) GetMeasurementsCalls() []struct{ ... }
- func (mock *AppMock) HandleSensorEvent(ctx context.Context, se application.SensorEvent) error
- func (mock *AppMock) HandleSensorEventCalls() []struct{ ... }
- func (mock *AppMock) HandleSensorMeasurementList(ctx context.Context, deviceID string, pack senml.Pack) error
- func (mock *AppMock) HandleSensorMeasurementListCalls() []struct{ ... }
- type StatusMessage
Constants ¶
View Source
const UNKNOWN = "unknown"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App interface { HandleSensorEvent(ctx context.Context, se application.SensorEvent) error HandleSensorMeasurementList(ctx context.Context, deviceID string, pack senml.Pack) error GetDevice(ctx context.Context, deviceID string) (dmc.Device, error) }
func New ¶
func New(dmc dmc.DeviceManagementClient, msgCtx messaging.MsgContext, createUnknownDeviceEnabled bool, createUnknownDeviceTenant string) App
type AppMock ¶
type AppMock struct { // GetDeviceFunc mocks the GetDevice method. GetDeviceFunc func(ctx context.Context, deviceID string) (dmc.Device, error) // GetMeasurementsFunc mocks the GetMeasurements method. GetMeasurementsFunc func(ctx context.Context, deviceID string, temprel string, t time.Time, et time.Time, lastN int) ([]application.Measurement, error) // HandleSensorEventFunc mocks the HandleSensorEvent method. HandleSensorEventFunc func(ctx context.Context, se application.SensorEvent) error // HandleSensorMeasurementListFunc mocks the HandleSensorMeasurementList method. HandleSensorMeasurementListFunc func(ctx context.Context, deviceID string, pack senml.Pack) error // contains filtered or unexported fields }
AppMock is a mock implementation of App.
func TestSomethingThatUsesApp(t *testing.T) { // make and configure a mocked App mockedApp := &AppMock{ GetDeviceFunc: func(ctx context.Context, deviceID string) (dmc.Device, error) { panic("mock out the GetDevice method") }, GetMeasurementsFunc: func(ctx context.Context, deviceID string, temprel string, t time.Time, et time.Time, lastN int) ([]application.Measurement, error) { panic("mock out the GetMeasurements method") }, HandleSensorEventFunc: func(ctx context.Context, se application.SensorEvent) error { panic("mock out the HandleSensorEvent method") }, HandleSensorMeasurementListFunc: func(ctx context.Context, deviceID string, pack senml.Pack) error { panic("mock out the HandleSensorMeasurementList method") }, } // use mockedApp in code that requires App // and then make assertions. }
func (*AppMock) GetDeviceCalls ¶
GetDeviceCalls gets all the calls that were made to GetDevice. Check the length with:
len(mockedApp.GetDeviceCalls())
func (*AppMock) GetMeasurements ¶
func (mock *AppMock) GetMeasurements(ctx context.Context, deviceID string, temprel string, t time.Time, et time.Time, lastN int) ([]application.Measurement, error)
GetMeasurements calls GetMeasurementsFunc.
func (*AppMock) GetMeasurementsCalls ¶
func (mock *AppMock) GetMeasurementsCalls() []struct { Ctx context.Context DeviceID string Temprel string T time.Time Et time.Time LastN int }
GetMeasurementsCalls gets all the calls that were made to GetMeasurements. Check the length with:
len(mockedApp.GetMeasurementsCalls())
func (*AppMock) HandleSensorEvent ¶
func (mock *AppMock) HandleSensorEvent(ctx context.Context, se application.SensorEvent) error
HandleSensorEvent calls HandleSensorEventFunc.
func (*AppMock) HandleSensorEventCalls ¶
func (mock *AppMock) HandleSensorEventCalls() []struct { Ctx context.Context Se application.SensorEvent }
HandleSensorEventCalls gets all the calls that were made to HandleSensorEvent. Check the length with:
len(mockedApp.HandleSensorEventCalls())
func (*AppMock) HandleSensorMeasurementList ¶
func (mock *AppMock) HandleSensorMeasurementList(ctx context.Context, deviceID string, pack senml.Pack) error
HandleSensorMeasurementList calls HandleSensorMeasurementListFunc.
func (*AppMock) HandleSensorMeasurementListCalls ¶
func (mock *AppMock) HandleSensorMeasurementListCalls() []struct { Ctx context.Context DeviceID string Pack senml.Pack }
HandleSensorMeasurementListCalls gets all the calls that were made to HandleSensorMeasurementList. Check the length with:
len(mockedApp.HandleSensorMeasurementListCalls())
type StatusMessage ¶
type StatusMessage struct { DeviceID string `json:"deviceID"` BatteryLevel int `json:"batteryLevel"` Code int `json:"statusCode"` Messages []string `json:"statusMessages,omitempty"` Tenant string `json:"tenant"` Timestamp time.Time `json:"timestamp"` }
func (*StatusMessage) Body ¶
func (m *StatusMessage) Body() []byte
func (*StatusMessage) ContentType ¶
func (m *StatusMessage) ContentType() string
func (*StatusMessage) TopicName ¶
func (m *StatusMessage) TopicName() string
Click to show internal directories.
Click to hide internal directories.