-
Notifications
You must be signed in to change notification settings - Fork 2
/
public_key_store_mock.go
198 lines (160 loc) · 6.67 KB
/
public_key_store_mock.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package cryptkit
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
)
// PublicKeyStoreMock implements PublicKeyStore
type PublicKeyStoreMock struct {
t minimock.Tester
funcPublicKeyStore func()
inspectFuncPublicKeyStore func()
afterPublicKeyStoreCounter uint64
beforePublicKeyStoreCounter uint64
PublicKeyStoreMock mPublicKeyStoreMockPublicKeyStore
}
// NewPublicKeyStoreMock returns a mock for PublicKeyStore
func NewPublicKeyStoreMock(t minimock.Tester) *PublicKeyStoreMock {
m := &PublicKeyStoreMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.PublicKeyStoreMock = mPublicKeyStoreMockPublicKeyStore{mock: m}
return m
}
type mPublicKeyStoreMockPublicKeyStore struct {
mock *PublicKeyStoreMock
defaultExpectation *PublicKeyStoreMockPublicKeyStoreExpectation
expectations []*PublicKeyStoreMockPublicKeyStoreExpectation
}
// PublicKeyStoreMockPublicKeyStoreExpectation specifies expectation struct of the PublicKeyStore.PublicKeyStore
type PublicKeyStoreMockPublicKeyStoreExpectation struct {
mock *PublicKeyStoreMock
Counter uint64
}
// Expect sets up expected params for PublicKeyStore.PublicKeyStore
func (mmPublicKeyStore *mPublicKeyStoreMockPublicKeyStore) Expect() *mPublicKeyStoreMockPublicKeyStore {
if mmPublicKeyStore.mock.funcPublicKeyStore != nil {
mmPublicKeyStore.mock.t.Fatalf("PublicKeyStoreMock.PublicKeyStore mock is already set by Set")
}
if mmPublicKeyStore.defaultExpectation == nil {
mmPublicKeyStore.defaultExpectation = &PublicKeyStoreMockPublicKeyStoreExpectation{}
}
return mmPublicKeyStore
}
// Inspect accepts an inspector function that has same arguments as the PublicKeyStore.PublicKeyStore
func (mmPublicKeyStore *mPublicKeyStoreMockPublicKeyStore) Inspect(f func()) *mPublicKeyStoreMockPublicKeyStore {
if mmPublicKeyStore.mock.inspectFuncPublicKeyStore != nil {
mmPublicKeyStore.mock.t.Fatalf("Inspect function is already set for PublicKeyStoreMock.PublicKeyStore")
}
mmPublicKeyStore.mock.inspectFuncPublicKeyStore = f
return mmPublicKeyStore
}
// Return sets up results that will be returned by PublicKeyStore.PublicKeyStore
func (mmPublicKeyStore *mPublicKeyStoreMockPublicKeyStore) Return() *PublicKeyStoreMock {
if mmPublicKeyStore.mock.funcPublicKeyStore != nil {
mmPublicKeyStore.mock.t.Fatalf("PublicKeyStoreMock.PublicKeyStore mock is already set by Set")
}
if mmPublicKeyStore.defaultExpectation == nil {
mmPublicKeyStore.defaultExpectation = &PublicKeyStoreMockPublicKeyStoreExpectation{mock: mmPublicKeyStore.mock}
}
return mmPublicKeyStore.mock
}
//Set uses given function f to mock the PublicKeyStore.PublicKeyStore method
func (mmPublicKeyStore *mPublicKeyStoreMockPublicKeyStore) Set(f func()) *PublicKeyStoreMock {
if mmPublicKeyStore.defaultExpectation != nil {
mmPublicKeyStore.mock.t.Fatalf("Default expectation is already set for the PublicKeyStore.PublicKeyStore method")
}
if len(mmPublicKeyStore.expectations) > 0 {
mmPublicKeyStore.mock.t.Fatalf("Some expectations are already set for the PublicKeyStore.PublicKeyStore method")
}
mmPublicKeyStore.mock.funcPublicKeyStore = f
return mmPublicKeyStore.mock
}
// PublicKeyStore implements PublicKeyStore
func (mmPublicKeyStore *PublicKeyStoreMock) PublicKeyStore() {
mm_atomic.AddUint64(&mmPublicKeyStore.beforePublicKeyStoreCounter, 1)
defer mm_atomic.AddUint64(&mmPublicKeyStore.afterPublicKeyStoreCounter, 1)
if mmPublicKeyStore.inspectFuncPublicKeyStore != nil {
mmPublicKeyStore.inspectFuncPublicKeyStore()
}
if mmPublicKeyStore.PublicKeyStoreMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmPublicKeyStore.PublicKeyStoreMock.defaultExpectation.Counter, 1)
return
}
if mmPublicKeyStore.funcPublicKeyStore != nil {
mmPublicKeyStore.funcPublicKeyStore()
return
}
mmPublicKeyStore.t.Fatalf("Unexpected call to PublicKeyStoreMock.PublicKeyStore.")
}
// PublicKeyStoreAfterCounter returns a count of finished PublicKeyStoreMock.PublicKeyStore invocations
func (mmPublicKeyStore *PublicKeyStoreMock) PublicKeyStoreAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmPublicKeyStore.afterPublicKeyStoreCounter)
}
// PublicKeyStoreBeforeCounter returns a count of PublicKeyStoreMock.PublicKeyStore invocations
func (mmPublicKeyStore *PublicKeyStoreMock) PublicKeyStoreBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmPublicKeyStore.beforePublicKeyStoreCounter)
}
// MinimockPublicKeyStoreDone returns true if the count of the PublicKeyStore invocations corresponds
// the number of defined expectations
func (m *PublicKeyStoreMock) MinimockPublicKeyStoreDone() bool {
for _, e := range m.PublicKeyStoreMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.PublicKeyStoreMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterPublicKeyStoreCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcPublicKeyStore != nil && mm_atomic.LoadUint64(&m.afterPublicKeyStoreCounter) < 1 {
return false
}
return true
}
// MinimockPublicKeyStoreInspect logs each unmet expectation
func (m *PublicKeyStoreMock) MinimockPublicKeyStoreInspect() {
for _, e := range m.PublicKeyStoreMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to PublicKeyStoreMock.PublicKeyStore")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.PublicKeyStoreMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterPublicKeyStoreCounter) < 1 {
m.t.Error("Expected call to PublicKeyStoreMock.PublicKeyStore")
}
// if func was set then invocations count should be greater than zero
if m.funcPublicKeyStore != nil && mm_atomic.LoadUint64(&m.afterPublicKeyStoreCounter) < 1 {
m.t.Error("Expected call to PublicKeyStoreMock.PublicKeyStore")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *PublicKeyStoreMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockPublicKeyStoreInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *PublicKeyStoreMock) MinimockWait(timeout mm_time.Duration) {
timeoutCh := mm_time.After(timeout)
for {
if m.minimockDone() {
return
}
select {
case <-timeoutCh:
m.MinimockFinish()
return
case <-mm_time.After(10 * mm_time.Millisecond):
}
}
}
func (m *PublicKeyStoreMock) minimockDone() bool {
done := true
return done &&
m.MinimockPublicKeyStoreDone()
}