add http server
This commit is contained in:
32
internal/store/mock/store.go
Normal file
32
internal/store/mock/store.go
Normal file
@ -0,0 +1,32 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user