Documentation ¶
Index ¶
- Constants
- Variables
- type Alarm
- type AlarmRepository
- type AlarmRepositoryMock
- func (mock *AlarmRepositoryMock) Add(ctx context.Context, alarm Alarm) (int, error)
- func (mock *AlarmRepositoryMock) AddCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) Close(ctx context.Context, alarmID int) error
- func (mock *AlarmRepositoryMock) CloseCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) GetAll(ctx context.Context, tenants ...string) ([]Alarm, error)
- func (mock *AlarmRepositoryMock) GetAllCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) GetByID(ctx context.Context, alarmID int) (Alarm, error)
- func (mock *AlarmRepositoryMock) GetByIDCalls() []struct{ ... }
- func (mock *AlarmRepositoryMock) GetByRefID(ctx context.Context, refID string) ([]Alarm, error)
- func (mock *AlarmRepositoryMock) GetByRefIDCalls() []struct{ ... }
Constants ¶
View Source
const ( AlarmSeverityLow = 1 AlarmSeverityMedium = 2 AlarmSeverityHigh = 3 )
Variables ¶
View Source
var ErrAlarmNotFound = fmt.Errorf("alarm not found")
Functions ¶
This section is empty.
Types ¶
type Alarm ¶
type Alarm struct { ID uint `gorm:"primarykey" json:"id"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` RefID string `json:"refID"` Type string `json:"type"` Severity int `json:"severity"` Description string `json:"description"` Tenant string `json:"tenant"` ObservedAt time.Time `json:"observedAt"` }
type AlarmRepository ¶
type AlarmRepository interface { GetAll(ctx context.Context, tenants ...string) ([]Alarm, error) GetByID(ctx context.Context, alarmID int) (Alarm, error) GetByRefID(ctx context.Context, refID string) ([]Alarm, error) Add(ctx context.Context, alarm Alarm) (int, error) Close(ctx context.Context, alarmID int) error }
func NewAlarmRepository ¶
func NewAlarmRepository(connect ConnectorFunc) (AlarmRepository, error)
type AlarmRepositoryMock ¶
type AlarmRepositoryMock struct { // AddFunc mocks the Add method. AddFunc func(ctx context.Context, alarm Alarm) (int, error) // CloseFunc mocks the Close method. CloseFunc func(ctx context.Context, alarmID int) error // GetAllFunc mocks the GetAll method. GetAllFunc func(ctx context.Context, tenants ...string) ([]Alarm, error) // GetByIDFunc mocks the GetByID method. GetByIDFunc func(ctx context.Context, alarmID int) (Alarm, error) // GetByRefIDFunc mocks the GetByRefID method. GetByRefIDFunc func(ctx context.Context, refID string) ([]Alarm, error) // contains filtered or unexported fields }
AlarmRepositoryMock is a mock implementation of AlarmRepository.
func TestSomethingThatUsesAlarmRepository(t *testing.T) { // make and configure a mocked AlarmRepository mockedAlarmRepository := &AlarmRepositoryMock{ AddFunc: func(ctx context.Context, alarm Alarm) (int, error) { panic("mock out the Add method") }, CloseFunc: func(ctx context.Context, alarmID int) error { panic("mock out the Close method") }, GetAllFunc: func(ctx context.Context, tenants ...string) ([]Alarm, error) { panic("mock out the GetAll method") }, GetByIDFunc: func(ctx context.Context, alarmID int) (Alarm, error) { panic("mock out the GetByID method") }, GetByRefIDFunc: func(ctx context.Context, refID string) ([]Alarm, error) { panic("mock out the GetByRefID method") }, } // use mockedAlarmRepository in code that requires AlarmRepository // and then make assertions. }
func (*AlarmRepositoryMock) AddCalls ¶
func (mock *AlarmRepositoryMock) AddCalls() []struct { Ctx context.Context Alarm Alarm }
AddCalls gets all the calls that were made to Add. Check the length with:
len(mockedAlarmRepository.AddCalls())
func (*AlarmRepositoryMock) Close ¶
func (mock *AlarmRepositoryMock) Close(ctx context.Context, alarmID int) error
Close calls CloseFunc.
func (*AlarmRepositoryMock) CloseCalls ¶
func (mock *AlarmRepositoryMock) CloseCalls() []struct { Ctx context.Context AlarmID int }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedAlarmRepository.CloseCalls())
func (*AlarmRepositoryMock) GetAllCalls ¶
func (mock *AlarmRepositoryMock) GetAllCalls() []struct { Ctx context.Context Tenants []string }
GetAllCalls gets all the calls that were made to GetAll. Check the length with:
len(mockedAlarmRepository.GetAllCalls())
func (*AlarmRepositoryMock) GetByIDCalls ¶
func (mock *AlarmRepositoryMock) GetByIDCalls() []struct { Ctx context.Context AlarmID int }
GetByIDCalls gets all the calls that were made to GetByID. Check the length with:
len(mockedAlarmRepository.GetByIDCalls())
func (*AlarmRepositoryMock) GetByRefID ¶
GetByRefID calls GetByRefIDFunc.
func (*AlarmRepositoryMock) GetByRefIDCalls ¶
func (mock *AlarmRepositoryMock) GetByRefIDCalls() []struct { Ctx context.Context RefID string }
GetByRefIDCalls gets all the calls that were made to GetByRefID. Check the length with:
len(mockedAlarmRepository.GetByRefIDCalls())
Click to show internal directories.
Click to hide internal directories.