33 lines
708 B
Go
33 lines
708 B
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.loyso.art/frx/devsim/internal/entities"
|
|
)
|
|
|
|
type MockedStore struct {
|
|
onList func() ([]entities.DeviceStatistics, error)
|
|
onUpsert func(stat entities.DeviceStatistics) (err error)
|
|
}
|
|
|
|
func NewMock() *MockedStore {
|
|
return &MockedStore{}
|
|
}
|
|
|
|
func (m *MockedStore) RegisterOnList(f func() ([]entities.DeviceStatistics, error)) {
|
|
m.onList = f
|
|
}
|
|
|
|
func (m *MockedStore) RegisterOnUpsert(f func(entities.DeviceStatistics) error) {
|
|
m.onUpsert = f
|
|
}
|
|
|
|
func (m *MockedStore) List(context.Context) ([]entities.DeviceStatistics, error) {
|
|
return m.onList()
|
|
}
|
|
|
|
func (m *MockedStore) Upsert(_ context.Context, stats entities.DeviceStatistics) error {
|
|
return m.onUpsert(stats)
|
|
}
|