-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmock_event_test.go
112 lines (102 loc) · 2.47 KB
/
mock_event_test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package cqrs_test
import (
"github.com/google/uuid"
"sync"
"github.com/theskyinflames/cqrs-eda/pkg/events"
)
// Ensure, that EventMock does implement events.Event.
// If this is not the case, regenerate this file with moq.
var _ events.Event = &EventMock{}
// EventMock is a mock implementation of events.Event.
//
// func TestSomethingThatUsesEvent(t *testing.T) {
//
// // make and configure a mocked events.Event
// mockedEvent := &EventMock{
// AggregateIDFunc: func() uuid.UUID {
// panic("mock out the AggregateID method")
// },
// NameFunc: func() string {
// panic("mock out the Name method")
// },
// }
//
// // use mockedEvent in code that requires events.Event
// // and then make assertions.
//
// }
type EventMock struct {
// AggregateIDFunc mocks the AggregateID method.
AggregateIDFunc func() uuid.UUID
// NameFunc mocks the Name method.
NameFunc func() string
// calls tracks calls to the methods.
calls struct {
// AggregateID holds details about calls to the AggregateID method.
AggregateID []struct {
}
// Name holds details about calls to the Name method.
Name []struct {
}
}
lockAggregateID sync.RWMutex
lockName sync.RWMutex
}
// AggregateID calls AggregateIDFunc.
func (mock *EventMock) AggregateID() uuid.UUID {
callInfo := struct {
}{}
mock.lockAggregateID.Lock()
mock.calls.AggregateID = append(mock.calls.AggregateID, callInfo)
mock.lockAggregateID.Unlock()
if mock.AggregateIDFunc == nil {
var (
uUIDOut uuid.UUID
)
return uUIDOut
}
return mock.AggregateIDFunc()
}
// AggregateIDCalls gets all the calls that were made to AggregateID.
// Check the length with:
//
// len(mockedEvent.AggregateIDCalls())
func (mock *EventMock) AggregateIDCalls() []struct {
} {
var calls []struct {
}
mock.lockAggregateID.RLock()
calls = mock.calls.AggregateID
mock.lockAggregateID.RUnlock()
return calls
}
// Name calls NameFunc.
func (mock *EventMock) Name() string {
callInfo := struct {
}{}
mock.lockName.Lock()
mock.calls.Name = append(mock.calls.Name, callInfo)
mock.lockName.Unlock()
if mock.NameFunc == nil {
var (
sOut string
)
return sOut
}
return mock.NameFunc()
}
// NameCalls gets all the calls that were made to Name.
// Check the length with:
//
// len(mockedEvent.NameCalls())
func (mock *EventMock) NameCalls() []struct {
} {
var calls []struct {
}
mock.lockName.RLock()
calls = mock.calls.Name
mock.lockName.RUnlock()
return calls
}