-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubsub_mock_test.go
254 lines (234 loc) · 6.64 KB
/
pubsub_mock_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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package go_pubsub
import (
"cloud.google.com/go/pubsub"
"context"
"sync"
)
// Ensure, that IPubSubClientMock does implement IPubSubClient.
// If this is not the case, regenerate this file with moq.
var _ IPubSubClient = &IPubSubClientMock{}
// IPubSubClientMock is a mock implementation of IPubSubClient.
//
// func TestSomethingThatUsesIPubSubClient(t *testing.T) {
//
// // make and configure a mocked IPubSubClient
// mockedIPubSubClient := &IPubSubClientMock{
// TopicFunc: func(id string) IPubSubTopic {
// panic("mock out the Topic method")
// },
// }
//
// // use mockedIPubSubClient in code that requires IPubSubClient
// // and then make assertions.
//
// }
type IPubSubClientMock struct {
// TopicFunc mocks the Topic method.
TopicFunc func(id string) IPubSubTopic
// calls tracks calls to the methods.
calls struct {
// Topic holds details about calls to the Topic method.
Topic []struct {
// ID is the id argument value.
ID string
}
}
lockTopic sync.RWMutex
}
// Topic calls TopicFunc.
func (mock *IPubSubClientMock) Topic(id string) IPubSubTopic {
if mock.TopicFunc == nil {
panic("IPubSubClientMock.TopicFunc: method is nil but IPubSubClient.Topic was just called")
}
callInfo := struct {
ID string
}{
ID: id,
}
mock.lockTopic.Lock()
mock.calls.Topic = append(mock.calls.Topic, callInfo)
mock.lockTopic.Unlock()
return mock.TopicFunc(id)
}
// TopicCalls gets all the calls that were made to Topic.
// Check the length with:
// len(mockedIPubSubClient.TopicCalls())
func (mock *IPubSubClientMock) TopicCalls() []struct {
ID string
} {
var calls []struct {
ID string
}
mock.lockTopic.RLock()
calls = mock.calls.Topic
mock.lockTopic.RUnlock()
return calls
}
// Ensure, that IPubSubTopicMock does implement IPubSubTopic.
// If this is not the case, regenerate this file with moq.
var _ IPubSubTopic = &IPubSubTopicMock{}
// IPubSubTopicMock is a mock implementation of IPubSubTopic.
//
// func TestSomethingThatUsesIPubSubTopic(t *testing.T) {
//
// // make and configure a mocked IPubSubTopic
// mockedIPubSubTopic := &IPubSubTopicMock{
// ExistsFunc: func(ctx context.Context) (bool, error) {
// panic("mock out the Exists method")
// },
// PublishFunc: func(ctx context.Context, msg *pubsub.Message) IPubSubPublishResult {
// panic("mock out the Publish method")
// },
// }
//
// // use mockedIPubSubTopic in code that requires IPubSubTopic
// // and then make assertions.
//
// }
type IPubSubTopicMock struct {
// ExistsFunc mocks the Exists method.
ExistsFunc func(ctx context.Context) (bool, error)
// PublishFunc mocks the Publish method.
PublishFunc func(ctx context.Context, msg *pubsub.Message) IPubSubPublishResult
// calls tracks calls to the methods.
calls struct {
// Exists holds details about calls to the Exists method.
Exists []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
// Publish holds details about calls to the Publish method.
Publish []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// Msg is the msg argument value.
Msg *pubsub.Message
}
}
lockExists sync.RWMutex
lockPublish sync.RWMutex
}
// Exists calls ExistsFunc.
func (mock *IPubSubTopicMock) Exists(ctx context.Context) (bool, error) {
if mock.ExistsFunc == nil {
panic("IPubSubTopicMock.ExistsFunc: method is nil but IPubSubTopic.Exists was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
mock.lockExists.Lock()
mock.calls.Exists = append(mock.calls.Exists, callInfo)
mock.lockExists.Unlock()
return mock.ExistsFunc(ctx)
}
// ExistsCalls gets all the calls that were made to Exists.
// Check the length with:
// len(mockedIPubSubTopic.ExistsCalls())
func (mock *IPubSubTopicMock) ExistsCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
mock.lockExists.RLock()
calls = mock.calls.Exists
mock.lockExists.RUnlock()
return calls
}
// Publish calls PublishFunc.
func (mock *IPubSubTopicMock) Publish(ctx context.Context, msg *pubsub.Message) IPubSubPublishResult {
if mock.PublishFunc == nil {
panic("IPubSubTopicMock.PublishFunc: method is nil but IPubSubTopic.Publish was just called")
}
callInfo := struct {
Ctx context.Context
Msg *pubsub.Message
}{
Ctx: ctx,
Msg: msg,
}
mock.lockPublish.Lock()
mock.calls.Publish = append(mock.calls.Publish, callInfo)
mock.lockPublish.Unlock()
return mock.PublishFunc(ctx, msg)
}
// PublishCalls gets all the calls that were made to Publish.
// Check the length with:
// len(mockedIPubSubTopic.PublishCalls())
func (mock *IPubSubTopicMock) PublishCalls() []struct {
Ctx context.Context
Msg *pubsub.Message
} {
var calls []struct {
Ctx context.Context
Msg *pubsub.Message
}
mock.lockPublish.RLock()
calls = mock.calls.Publish
mock.lockPublish.RUnlock()
return calls
}
// Ensure, that IPubSubPublishResultMock does implement IPubSubPublishResult.
// If this is not the case, regenerate this file with moq.
var _ IPubSubPublishResult = &IPubSubPublishResultMock{}
// IPubSubPublishResultMock is a mock implementation of IPubSubPublishResult.
//
// func TestSomethingThatUsesIPubSubPublishResult(t *testing.T) {
//
// // make and configure a mocked IPubSubPublishResult
// mockedIPubSubPublishResult := &IPubSubPublishResultMock{
// GetFunc: func(ctx context.Context) (string, error) {
// panic("mock out the Get method")
// },
// }
//
// // use mockedIPubSubPublishResult in code that requires IPubSubPublishResult
// // and then make assertions.
//
// }
type IPubSubPublishResultMock struct {
// GetFunc mocks the Get method.
GetFunc func(ctx context.Context) (string, error)
// calls tracks calls to the methods.
calls struct {
// Get holds details about calls to the Get method.
Get []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
}
lockGet sync.RWMutex
}
// Get calls GetFunc.
func (mock *IPubSubPublishResultMock) Get(ctx context.Context) (string, error) {
if mock.GetFunc == nil {
panic("IPubSubPublishResultMock.GetFunc: method is nil but IPubSubPublishResult.Get was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
mock.lockGet.Lock()
mock.calls.Get = append(mock.calls.Get, callInfo)
mock.lockGet.Unlock()
return mock.GetFunc(ctx)
}
// GetCalls gets all the calls that were made to Get.
// Check the length with:
// len(mockedIPubSubPublishResult.GetCalls())
func (mock *IPubSubPublishResultMock) GetCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
mock.lockGet.RLock()
calls = mock.calls.Get
mock.lockGet.RUnlock()
return calls
}