-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock-backend.go
49 lines (39 loc) · 1.18 KB
/
mock-backend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package backend
import (
"github.com/lucacox/event-sourcing/registry"
"github.com/stretchr/testify/mock"
)
type MockBackend struct {
mock.Mock
}
func (m *MockBackend) Connect() error {
args := m.Called()
return args.Error(0)
}
func (m *MockBackend) Close() error {
args := m.Called()
return args.Error(0)
}
func (m *MockBackend) SetEventRegistry(er *registry.EventRegistry) {
m.Called(er)
}
func (m *MockBackend) Setup(name string, replicationFactor int) error {
args := m.Called(name, replicationFactor)
return args.Error(0)
}
func (m *MockBackend) Save(events []*registry.Event, expectedSeq uint64) (uint64, error) {
args := m.Called(events, expectedSeq)
return args.Get(0).(uint64), args.Error(1)
}
func (m *MockBackend) Load() (map[string]*registry.Event, error) {
args := m.Called()
return args.Get(0).(map[string]*registry.Event), args.Error(1)
}
func (m *MockBackend) LoadByEntityId(id string) ([]*registry.Event, error) {
args := m.Called(id)
return args.Get(0).([]*registry.Event), args.Error(1)
}
func (m *MockBackend) LoadByEventType(eventType string) ([]*registry.Event, error) {
args := m.Called(eventType)
return args.Get(0).([]*registry.Event), args.Error(1)
}