alarms

package
v0.0.0-...-905d515 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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) Add

func (mock *AlarmRepositoryMock) Add(ctx context.Context, alarm Alarm) (int, error)

Add calls AddFunc.

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) GetAll

func (mock *AlarmRepositoryMock) GetAll(ctx context.Context, tenants ...string) ([]Alarm, error)

GetAll calls GetAllFunc.

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) GetByID

func (mock *AlarmRepositoryMock) GetByID(ctx context.Context, alarmID int) (Alarm, error)

GetByID calls GetByIDFunc.

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

func (mock *AlarmRepositoryMock) GetByRefID(ctx context.Context, refID string) ([]Alarm, error)

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())

Jump to

Keyboard shortcuts

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