-
Notifications
You must be signed in to change notification settings - Fork 0
/
crm_mock.go
269 lines (250 loc) · 8.75 KB
/
crm_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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package go_hubspot
import (
"bytes"
"sync"
)
// Ensure, that IHubspotCRMAPIMock does implement IHubspotCRMAPI.
// If this is not the case, regenerate this file with moq.
var _ IHubspotCRMAPI = &IHubspotCRMAPIMock{}
// IHubspotCRMAPIMock is a mock implementation of IHubspotCRMAPI.
//
// func TestSomethingThatUsesIHubspotCRMAPI(t *testing.T) {
//
// // make and configure a mocked IHubspotCRMAPI
// mockedIHubspotCRMAPI := &IHubspotCRMAPIMock{
// GetCompanyForContactFunc: func(contactID string) (string, error) {
// panic("mock out the GetCompanyForContact method")
// },
// GetDealForCompanyFunc: func(companyID string) (string, error) {
// panic("mock out the GetDealForCompany method")
// },
// SearchCompaniesFunc: func(filterMap map[string]string, properties []string) ([]HubSpotSearchResult, error) {
// panic("mock out the SearchCompanies method")
// },
// SearchContactsFunc: func(filterMap map[string]string, properties []string) ([]HubSpotSearchResult, error) {
// panic("mock out the SearchContacts method")
// },
// UpdateCompanyFunc: func(companyID string, jsonPayload *bytes.Buffer) error {
// panic("mock out the UpdateCompany method")
// },
// }
//
// // use mockedIHubspotCRMAPI in code that requires IHubspotCRMAPI
// // and then make assertions.
//
// }
type IHubspotCRMAPIMock struct {
// GetCompanyForContactFunc mocks the GetCompanyForContact method.
GetCompanyForContactFunc func(contactID string) (string, error)
// GetDealForCompanyFunc mocks the GetDealForCompany method.
GetDealForCompanyFunc func(companyID string) (string, error)
// SearchCompaniesFunc mocks the SearchCompanies method.
SearchCompaniesFunc func(filterMap map[string]string, properties []string) ([]HubSpotSearchResult, error)
// SearchContactsFunc mocks the SearchContacts method.
SearchContactsFunc func(filterMap map[string]string, properties []string) ([]HubSpotSearchResult, error)
// UpdateCompanyFunc mocks the UpdateCompany method.
UpdateCompanyFunc func(companyID string, jsonPayload *bytes.Buffer) error
// calls tracks calls to the methods.
calls struct {
// GetCompanyForContact holds details about calls to the GetCompanyForContact method.
GetCompanyForContact []struct {
// ContactID is the contactID argument value.
ContactID string
}
// GetDealForCompany holds details about calls to the GetDealForCompany method.
GetDealForCompany []struct {
// CompanyID is the companyID argument value.
CompanyID string
}
// SearchCompanies holds details about calls to the SearchCompanies method.
SearchCompanies []struct {
// FilterMap is the filterMap argument value.
FilterMap map[string]string
// Properties is the properties argument value.
Properties []string
}
// SearchContacts holds details about calls to the SearchContacts method.
SearchContacts []struct {
// FilterMap is the filterMap argument value.
FilterMap map[string]string
// Properties is the properties argument value.
Properties []string
}
// UpdateCompany holds details about calls to the UpdateCompany method.
UpdateCompany []struct {
// CompanyID is the companyID argument value.
CompanyID string
// JsonPayload is the jsonPayload argument value.
JsonPayload *bytes.Buffer
}
}
lockGetCompanyForContact sync.RWMutex
lockGetDealForCompany sync.RWMutex
lockSearchCompanies sync.RWMutex
lockSearchContacts sync.RWMutex
lockUpdateCompany sync.RWMutex
}
// GetCompanyForContact calls GetCompanyForContactFunc.
func (mock *IHubspotCRMAPIMock) GetCompanyForContact(contactID string) (string, error) {
if mock.GetCompanyForContactFunc == nil {
panic("IHubspotCRMAPIMock.GetCompanyForContactFunc: method is nil but IHubspotCRMAPI.GetCompanyForContact was just called")
}
callInfo := struct {
ContactID string
}{
ContactID: contactID,
}
mock.lockGetCompanyForContact.Lock()
mock.calls.GetCompanyForContact = append(mock.calls.GetCompanyForContact, callInfo)
mock.lockGetCompanyForContact.Unlock()
return mock.GetCompanyForContactFunc(contactID)
}
// GetCompanyForContactCalls gets all the calls that were made to GetCompanyForContact.
// Check the length with:
//
// len(mockedIHubspotCRMAPI.GetCompanyForContactCalls())
func (mock *IHubspotCRMAPIMock) GetCompanyForContactCalls() []struct {
ContactID string
} {
var calls []struct {
ContactID string
}
mock.lockGetCompanyForContact.RLock()
calls = mock.calls.GetCompanyForContact
mock.lockGetCompanyForContact.RUnlock()
return calls
}
// GetDealForCompany calls GetDealForCompanyFunc.
func (mock *IHubspotCRMAPIMock) GetDealForCompany(companyID string) (string, error) {
if mock.GetDealForCompanyFunc == nil {
panic("IHubspotCRMAPIMock.GetDealForCompanyFunc: method is nil but IHubspotCRMAPI.GetDealForCompany was just called")
}
callInfo := struct {
CompanyID string
}{
CompanyID: companyID,
}
mock.lockGetDealForCompany.Lock()
mock.calls.GetDealForCompany = append(mock.calls.GetDealForCompany, callInfo)
mock.lockGetDealForCompany.Unlock()
return mock.GetDealForCompanyFunc(companyID)
}
// GetDealForCompanyCalls gets all the calls that were made to GetDealForCompany.
// Check the length with:
//
// len(mockedIHubspotCRMAPI.GetDealForCompanyCalls())
func (mock *IHubspotCRMAPIMock) GetDealForCompanyCalls() []struct {
CompanyID string
} {
var calls []struct {
CompanyID string
}
mock.lockGetDealForCompany.RLock()
calls = mock.calls.GetDealForCompany
mock.lockGetDealForCompany.RUnlock()
return calls
}
// SearchCompanies calls SearchCompaniesFunc.
func (mock *IHubspotCRMAPIMock) SearchCompanies(filterMap map[string]string, properties []string) ([]HubSpotSearchResult, error) {
if mock.SearchCompaniesFunc == nil {
panic("IHubspotCRMAPIMock.SearchCompaniesFunc: method is nil but IHubspotCRMAPI.SearchCompanies was just called")
}
callInfo := struct {
FilterMap map[string]string
Properties []string
}{
FilterMap: filterMap,
Properties: properties,
}
mock.lockSearchCompanies.Lock()
mock.calls.SearchCompanies = append(mock.calls.SearchCompanies, callInfo)
mock.lockSearchCompanies.Unlock()
return mock.SearchCompaniesFunc(filterMap, properties)
}
// SearchCompaniesCalls gets all the calls that were made to SearchCompanies.
// Check the length with:
//
// len(mockedIHubspotCRMAPI.SearchCompaniesCalls())
func (mock *IHubspotCRMAPIMock) SearchCompaniesCalls() []struct {
FilterMap map[string]string
Properties []string
} {
var calls []struct {
FilterMap map[string]string
Properties []string
}
mock.lockSearchCompanies.RLock()
calls = mock.calls.SearchCompanies
mock.lockSearchCompanies.RUnlock()
return calls
}
// SearchContacts calls SearchContactsFunc.
func (mock *IHubspotCRMAPIMock) SearchContacts(filterMap map[string]string, properties []string) ([]HubSpotSearchResult, error) {
if mock.SearchContactsFunc == nil {
panic("IHubspotCRMAPIMock.SearchContactsFunc: method is nil but IHubspotCRMAPI.SearchContacts was just called")
}
callInfo := struct {
FilterMap map[string]string
Properties []string
}{
FilterMap: filterMap,
Properties: properties,
}
mock.lockSearchContacts.Lock()
mock.calls.SearchContacts = append(mock.calls.SearchContacts, callInfo)
mock.lockSearchContacts.Unlock()
return mock.SearchContactsFunc(filterMap, properties)
}
// SearchContactsCalls gets all the calls that were made to SearchContacts.
// Check the length with:
//
// len(mockedIHubspotCRMAPI.SearchContactsCalls())
func (mock *IHubspotCRMAPIMock) SearchContactsCalls() []struct {
FilterMap map[string]string
Properties []string
} {
var calls []struct {
FilterMap map[string]string
Properties []string
}
mock.lockSearchContacts.RLock()
calls = mock.calls.SearchContacts
mock.lockSearchContacts.RUnlock()
return calls
}
// UpdateCompany calls UpdateCompanyFunc.
func (mock *IHubspotCRMAPIMock) UpdateCompany(companyID string, jsonPayload *bytes.Buffer) error {
if mock.UpdateCompanyFunc == nil {
panic("IHubspotCRMAPIMock.UpdateCompanyFunc: method is nil but IHubspotCRMAPI.UpdateCompany was just called")
}
callInfo := struct {
CompanyID string
JsonPayload *bytes.Buffer
}{
CompanyID: companyID,
JsonPayload: jsonPayload,
}
mock.lockUpdateCompany.Lock()
mock.calls.UpdateCompany = append(mock.calls.UpdateCompany, callInfo)
mock.lockUpdateCompany.Unlock()
return mock.UpdateCompanyFunc(companyID, jsonPayload)
}
// UpdateCompanyCalls gets all the calls that were made to UpdateCompany.
// Check the length with:
//
// len(mockedIHubspotCRMAPI.UpdateCompanyCalls())
func (mock *IHubspotCRMAPIMock) UpdateCompanyCalls() []struct {
CompanyID string
JsonPayload *bytes.Buffer
} {
var calls []struct {
CompanyID string
JsonPayload *bytes.Buffer
}
mock.lockUpdateCompany.RLock()
calls = mock.calls.UpdateCompany
mock.lockUpdateCompany.RUnlock()
return calls
}