Documentation ¶
Index ¶
- Constants
- Variables
- type Alarm
- type Device
- type DeviceProfile
- type DeviceRepository
- type DeviceRepositoryMock
- func (mock *DeviceRepositoryMock) AddAlarm(ctx context.Context, deviceID string, alarmID int, severity int, ...) error
- func (mock *DeviceRepositoryMock) AddAlarmCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) GetDeviceByDeviceID(ctx context.Context, deviceID string, tenants ...string) (Device, error)
- func (mock *DeviceRepositoryMock) GetDeviceByDeviceIDCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) GetDeviceBySensorID(ctx context.Context, sensorID string, tenants ...string) (Device, error)
- func (mock *DeviceRepositoryMock) GetDeviceBySensorIDCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) GetDevices(ctx context.Context, tenants ...string) ([]Device, error)
- func (mock *DeviceRepositoryMock) GetDevicesCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) GetOnlineDevices(ctx context.Context, tenants ...string) ([]Device, error)
- func (mock *DeviceRepositoryMock) GetOnlineDevicesCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) RemoveAlarmByID(ctx context.Context, alarmID int) (string, error)
- func (mock *DeviceRepositoryMock) RemoveAlarmByIDCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) Save(ctx context.Context, device *Device) error
- func (mock *DeviceRepositoryMock) SaveCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) Seed(contextMoqParam context.Context, reader io.Reader, strings ...string) error
- func (mock *DeviceRepositoryMock) SeedCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) UpdateDeviceState(ctx context.Context, deviceID string, deviceState DeviceState) error
- func (mock *DeviceRepositoryMock) UpdateDeviceStateCalls() []struct{ ... }
- func (mock *DeviceRepositoryMock) UpdateDeviceStatus(ctx context.Context, deviceID string, deviceStatus DeviceStatus) error
- func (mock *DeviceRepositoryMock) UpdateDeviceStatusCalls() []struct{ ... }
- type DeviceState
- type DeviceStatus
- type Location
- type Lwm2mType
- type Tag
- type Tenant
Constants ¶
const ( DeviceStateUnknown = -1 DeviceStateOK = 1 DeviceStateWarning = 2 DeviceStateError = 3 )
Variables ¶
var ErrDeviceNotFound = fmt.Errorf("device not found")
var ErrRepositoryError = fmt.Errorf("could not fetch data from repository")
Functions ¶
This section is empty.
Types ¶
type Alarm ¶
type Device ¶
type Device struct { gorm.Model `json:"-"` SensorID string `gorm:"uniqueIndex" json:"sensorID"` DeviceID string `gorm:"uniqueIndex" json:"deviceID"` Active bool `json:"active"` Name string `json:"name"` Description string `json:"description"` Location Location `json:"location"` Environment string `json:"environment"` Source string `json:"source"` DeviceStatus DeviceStatus `json:"deviceStatus"` DeviceState DeviceState `json:"deviceState"` TenantID uint `gorm:"foreignKey:TenantID" json:"-"` Tenant Tenant `json:"tenant"` DeviceProfileID uint `gorm:"foreignKey:DeviceProfileID" json:"-"` DeviceProfile DeviceProfile `json:"deviceProfile"` Lwm2mTypes []Lwm2mType `gorm:"many2many:device_lwm2mType;" json:"types"` Tags []Tag `gorm:"many2many:device_tags;" json:"tags"` Alarms []Alarm `json:"-"` }
type DeviceProfile ¶
type DeviceRepository ¶
type DeviceRepository interface { GetDevices(ctx context.Context, tenants ...string) ([]Device, error) GetOnlineDevices(ctx context.Context, tenants ...string) ([]Device, error) GetDeviceBySensorID(ctx context.Context, sensorID string, tenants ...string) (Device, error) GetDeviceByDeviceID(ctx context.Context, deviceID string, tenants ...string) (Device, error) Save(ctx context.Context, device *Device) error UpdateDeviceStatus(ctx context.Context, deviceID string, deviceStatus DeviceStatus) error UpdateDeviceState(ctx context.Context, deviceID string, deviceState DeviceState) error AddAlarm(ctx context.Context, deviceID string, alarmID int, severity int, observedAt time.Time) error RemoveAlarmByID(ctx context.Context, alarmID int) (string, error) Seed(context.Context, io.Reader, ...string) error }
func NewDeviceRepository ¶
func NewDeviceRepository(connect ConnectorFunc) (DeviceRepository, error)
type DeviceRepositoryMock ¶
type DeviceRepositoryMock struct { // AddAlarmFunc mocks the AddAlarm method. AddAlarmFunc func(ctx context.Context, deviceID string, alarmID int, severity int, observedAt time.Time) error // GetDeviceByDeviceIDFunc mocks the GetDeviceByDeviceID method. GetDeviceByDeviceIDFunc func(ctx context.Context, deviceID string, tenants ...string) (Device, error) // GetDeviceBySensorIDFunc mocks the GetDeviceBySensorID method. GetDeviceBySensorIDFunc func(ctx context.Context, sensorID string, tenants ...string) (Device, error) // GetDevicesFunc mocks the GetDevices method. GetDevicesFunc func(ctx context.Context, tenants ...string) ([]Device, error) // GetOnlineDevicesFunc mocks the GetOnlineDevices method. GetOnlineDevicesFunc func(ctx context.Context, tenants ...string) ([]Device, error) // RemoveAlarmByIDFunc mocks the RemoveAlarmByID method. RemoveAlarmByIDFunc func(ctx context.Context, alarmID int) (string, error) // SaveFunc mocks the Save method. SaveFunc func(ctx context.Context, device *Device) error // SeedFunc mocks the Seed method. SeedFunc func(contextMoqParam context.Context, reader io.Reader, strings ...string) error // UpdateDeviceStateFunc mocks the UpdateDeviceState method. UpdateDeviceStateFunc func(ctx context.Context, deviceID string, deviceState DeviceState) error // UpdateDeviceStatusFunc mocks the UpdateDeviceStatus method. UpdateDeviceStatusFunc func(ctx context.Context, deviceID string, deviceStatus DeviceStatus) error // contains filtered or unexported fields }
DeviceRepositoryMock is a mock implementation of DeviceRepository.
func TestSomethingThatUsesDeviceRepository(t *testing.T) { // make and configure a mocked DeviceRepository mockedDeviceRepository := &DeviceRepositoryMock{ AddAlarmFunc: func(ctx context.Context, deviceID string, alarmID int, severity int, observedAt time.Time) error { panic("mock out the AddAlarm method") }, GetDeviceByDeviceIDFunc: func(ctx context.Context, deviceID string, tenants ...string) (Device, error) { panic("mock out the GetDeviceByDeviceID method") }, GetDeviceBySensorIDFunc: func(ctx context.Context, sensorID string, tenants ...string) (Device, error) { panic("mock out the GetDeviceBySensorID method") }, GetDevicesFunc: func(ctx context.Context, tenants ...string) ([]Device, error) { panic("mock out the GetDevices method") }, GetOnlineDevicesFunc: func(ctx context.Context, tenants ...string) ([]Device, error) { panic("mock out the GetOnlineDevices method") }, RemoveAlarmByIDFunc: func(ctx context.Context, alarmID int) (string, error) { panic("mock out the RemoveAlarmByID method") }, SaveFunc: func(ctx context.Context, device *Device) error { panic("mock out the Save method") }, SeedFunc: func(contextMoqParam context.Context, reader io.Reader, strings ...string) error { panic("mock out the Seed method") }, UpdateDeviceStateFunc: func(ctx context.Context, deviceID string, deviceState DeviceState) error { panic("mock out the UpdateDeviceState method") }, UpdateDeviceStatusFunc: func(ctx context.Context, deviceID string, deviceStatus DeviceStatus) error { panic("mock out the UpdateDeviceStatus method") }, } // use mockedDeviceRepository in code that requires DeviceRepository // and then make assertions. }
func (*DeviceRepositoryMock) AddAlarm ¶
func (mock *DeviceRepositoryMock) AddAlarm(ctx context.Context, deviceID string, alarmID int, severity int, observedAt time.Time) error
AddAlarm calls AddAlarmFunc.
func (*DeviceRepositoryMock) AddAlarmCalls ¶
func (mock *DeviceRepositoryMock) AddAlarmCalls() []struct { Ctx context.Context DeviceID string AlarmID int Severity int ObservedAt time.Time }
AddAlarmCalls gets all the calls that were made to AddAlarm. Check the length with:
len(mockedDeviceRepository.AddAlarmCalls())
func (*DeviceRepositoryMock) GetDeviceByDeviceID ¶
func (mock *DeviceRepositoryMock) GetDeviceByDeviceID(ctx context.Context, deviceID string, tenants ...string) (Device, error)
GetDeviceByDeviceID calls GetDeviceByDeviceIDFunc.
func (*DeviceRepositoryMock) GetDeviceByDeviceIDCalls ¶
func (mock *DeviceRepositoryMock) GetDeviceByDeviceIDCalls() []struct { Ctx context.Context DeviceID string Tenants []string }
GetDeviceByDeviceIDCalls gets all the calls that were made to GetDeviceByDeviceID. Check the length with:
len(mockedDeviceRepository.GetDeviceByDeviceIDCalls())
func (*DeviceRepositoryMock) GetDeviceBySensorID ¶
func (mock *DeviceRepositoryMock) GetDeviceBySensorID(ctx context.Context, sensorID string, tenants ...string) (Device, error)
GetDeviceBySensorID calls GetDeviceBySensorIDFunc.
func (*DeviceRepositoryMock) GetDeviceBySensorIDCalls ¶
func (mock *DeviceRepositoryMock) GetDeviceBySensorIDCalls() []struct { Ctx context.Context SensorID string Tenants []string }
GetDeviceBySensorIDCalls gets all the calls that were made to GetDeviceBySensorID. Check the length with:
len(mockedDeviceRepository.GetDeviceBySensorIDCalls())
func (*DeviceRepositoryMock) GetDevices ¶
func (mock *DeviceRepositoryMock) GetDevices(ctx context.Context, tenants ...string) ([]Device, error)
GetDevices calls GetDevicesFunc.
func (*DeviceRepositoryMock) GetDevicesCalls ¶
func (mock *DeviceRepositoryMock) GetDevicesCalls() []struct { Ctx context.Context Tenants []string }
GetDevicesCalls gets all the calls that were made to GetDevices. Check the length with:
len(mockedDeviceRepository.GetDevicesCalls())
func (*DeviceRepositoryMock) GetOnlineDevices ¶
func (mock *DeviceRepositoryMock) GetOnlineDevices(ctx context.Context, tenants ...string) ([]Device, error)
GetOnlineDevices calls GetOnlineDevicesFunc.
func (*DeviceRepositoryMock) GetOnlineDevicesCalls ¶
func (mock *DeviceRepositoryMock) GetOnlineDevicesCalls() []struct { Ctx context.Context Tenants []string }
GetOnlineDevicesCalls gets all the calls that were made to GetOnlineDevices. Check the length with:
len(mockedDeviceRepository.GetOnlineDevicesCalls())
func (*DeviceRepositoryMock) RemoveAlarmByID ¶
RemoveAlarmByID calls RemoveAlarmByIDFunc.
func (*DeviceRepositoryMock) RemoveAlarmByIDCalls ¶
func (mock *DeviceRepositoryMock) RemoveAlarmByIDCalls() []struct { Ctx context.Context AlarmID int }
RemoveAlarmByIDCalls gets all the calls that were made to RemoveAlarmByID. Check the length with:
len(mockedDeviceRepository.RemoveAlarmByIDCalls())
func (*DeviceRepositoryMock) Save ¶
func (mock *DeviceRepositoryMock) Save(ctx context.Context, device *Device) error
Save calls SaveFunc.
func (*DeviceRepositoryMock) SaveCalls ¶
func (mock *DeviceRepositoryMock) SaveCalls() []struct { Ctx context.Context Device *Device }
SaveCalls gets all the calls that were made to Save. Check the length with:
len(mockedDeviceRepository.SaveCalls())
func (*DeviceRepositoryMock) Seed ¶
func (mock *DeviceRepositoryMock) Seed(contextMoqParam context.Context, reader io.Reader, strings ...string) error
Seed calls SeedFunc.
func (*DeviceRepositoryMock) SeedCalls ¶
func (mock *DeviceRepositoryMock) SeedCalls() []struct { ContextMoqParam context.Context Reader io.Reader Strings []string }
SeedCalls gets all the calls that were made to Seed. Check the length with:
len(mockedDeviceRepository.SeedCalls())
func (*DeviceRepositoryMock) UpdateDeviceState ¶
func (mock *DeviceRepositoryMock) UpdateDeviceState(ctx context.Context, deviceID string, deviceState DeviceState) error
UpdateDeviceState calls UpdateDeviceStateFunc.
func (*DeviceRepositoryMock) UpdateDeviceStateCalls ¶
func (mock *DeviceRepositoryMock) UpdateDeviceStateCalls() []struct { Ctx context.Context DeviceID string DeviceState DeviceState }
UpdateDeviceStateCalls gets all the calls that were made to UpdateDeviceState. Check the length with:
len(mockedDeviceRepository.UpdateDeviceStateCalls())
func (*DeviceRepositoryMock) UpdateDeviceStatus ¶
func (mock *DeviceRepositoryMock) UpdateDeviceStatus(ctx context.Context, deviceID string, deviceStatus DeviceStatus) error
UpdateDeviceStatus calls UpdateDeviceStatusFunc.
func (*DeviceRepositoryMock) UpdateDeviceStatusCalls ¶
func (mock *DeviceRepositoryMock) UpdateDeviceStatusCalls() []struct { Ctx context.Context DeviceID string DeviceStatus DeviceStatus }
UpdateDeviceStatusCalls gets all the calls that were made to UpdateDeviceStatus. Check the length with:
len(mockedDeviceRepository.UpdateDeviceStatusCalls())