Skip to content

Commit d64cd69

Browse files
authored
[ENG-2914] feat(salesforce): Batch Unit Tests (#2255)
1 parent f60abd3 commit d64cd69

12 files changed

Lines changed: 576 additions & 28 deletions

File tree

providers/hubspot/batch-write_test.go

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ func TestBatchCreate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
6060
},
6161
Server: mockserver.Conditional{
6262
Setup: mockserver.ContentJSON(),
63-
If: mockcond.Path("/crm/v3/objects/contacts/batch/create"),
64-
Then: mockserver.Response(http.StatusConflict, errConflictExisting),
63+
If: mockcond.And{
64+
mockcond.MethodPOST(),
65+
mockcond.Path("/crm/v3/objects/contacts/batch/create"),
66+
},
67+
Then: mockserver.Response(http.StatusConflict, errConflictExisting),
6568
}.Server(),
6669
Comparator: testroutines.ComparatorSubsetBatchWrite,
6770
Expected: &common.BatchWriteResult{
@@ -82,8 +85,11 @@ func TestBatchCreate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
8285
},
8386
Server: mockserver.Conditional{
8487
Setup: mockserver.ContentJSON(),
85-
If: mockcond.Path("/crm/v3/objects/contacts/batch/create"),
86-
Then: mockserver.Response(http.StatusBadRequest, nil),
88+
If: mockcond.And{
89+
mockcond.MethodPOST(),
90+
mockcond.Path("/crm/v3/objects/contacts/batch/create"),
91+
},
92+
Then: mockserver.Response(http.StatusBadRequest, nil),
8793
}.Server(),
8894
Comparator: testroutines.ComparatorSubsetBatchWrite,
8995
Expected: &common.BatchWriteResult{
@@ -104,8 +110,11 @@ func TestBatchCreate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
104110
},
105111
Server: mockserver.Conditional{
106112
Setup: mockserver.ContentJSON(),
107-
If: mockcond.Path("/crm/v3/objects/contacts/batch/create"),
108-
Then: mockserver.Response(http.StatusBadRequest, errManyInvalidFields),
113+
If: mockcond.And{
114+
mockcond.MethodPOST(),
115+
mockcond.Path("/crm/v3/objects/contacts/batch/create"),
116+
},
117+
Then: mockserver.Response(http.StatusBadRequest, errManyInvalidFields),
109118
}.Server(),
110119
Comparator: testroutines.ComparatorSubsetBatchWrite,
111120
Expected: &common.BatchWriteResult{
@@ -142,8 +151,11 @@ func TestBatchCreate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
142151
},
143152
Server: mockserver.Conditional{
144153
Setup: mockserver.ContentJSON(),
145-
If: mockcond.Path("/crm/v3/objects/contacts/batch/create"),
146-
Then: mockserver.Response(http.StatusOK, responseCreateContacts),
154+
If: mockcond.And{
155+
mockcond.MethodPOST(),
156+
mockcond.Path("/crm/v3/objects/contacts/batch/create"),
157+
},
158+
Then: mockserver.Response(http.StatusOK, responseCreateContacts),
147159
}.Server(),
148160
Comparator: testroutines.ComparatorSubsetBatchWrite,
149161
Expected: &common.BatchWriteResult{
@@ -219,8 +231,11 @@ func TestBatchUpdate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
219231
},
220232
Server: mockserver.Conditional{
221233
Setup: mockserver.ContentJSON(),
222-
If: mockcond.Path("/crm/v3/objects/contacts/batch/update"),
223-
Then: mockserver.Response(http.StatusBadRequest, errDuplicateIDs),
234+
If: mockcond.And{
235+
mockcond.MethodPOST(),
236+
mockcond.Path("/crm/v3/objects/contacts/batch/update"),
237+
},
238+
Then: mockserver.Response(http.StatusBadRequest, errDuplicateIDs),
224239
}.Server(),
225240
Comparator: testroutines.ComparatorSubsetBatchWrite,
226241
Expected: &common.BatchWriteResult{
@@ -241,8 +256,11 @@ func TestBatchUpdate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
241256
},
242257
Server: mockserver.Conditional{
243258
Setup: mockserver.ContentJSON(),
244-
If: mockcond.Path("/crm/v3/objects/contacts/batch/update"),
245-
Then: mockserver.Response(http.StatusBadRequest, errManyInvalidFields),
259+
If: mockcond.And{
260+
mockcond.MethodPOST(),
261+
mockcond.Path("/crm/v3/objects/contacts/batch/update"),
262+
},
263+
Then: mockserver.Response(http.StatusBadRequest, errManyInvalidFields),
246264
}.Server(),
247265
Comparator: testroutines.ComparatorSubsetBatchWrite,
248266
Expected: &common.BatchWriteResult{
@@ -293,8 +311,11 @@ func TestBatchUpdate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
293311
},
294312
Server: mockserver.Conditional{
295313
Setup: mockserver.ContentJSON(),
296-
If: mockcond.Path("/crm/v3/objects/contacts/batch/update"),
297-
Then: mockserver.Response(http.StatusMultiStatus, errUpdatePartial),
314+
If: mockcond.And{
315+
mockcond.MethodPOST(),
316+
mockcond.Path("/crm/v3/objects/contacts/batch/update"),
317+
},
318+
Then: mockserver.Response(http.StatusMultiStatus, errUpdatePartial),
298319
}.Server(),
299320
Comparator: testroutines.ComparatorSubsetBatchWrite,
300321
Expected: &common.BatchWriteResult{
@@ -333,8 +354,11 @@ func TestBatchUpdate(t *testing.T) { // nolint:funlen,gocognit,cyclop,maintidx
333354
},
334355
Server: mockserver.Conditional{
335356
Setup: mockserver.ContentJSON(),
336-
If: mockcond.Path("/crm/v3/objects/contacts/batch/update"),
337-
Then: mockserver.Response(http.StatusOK, responseUpdateContacts),
357+
If: mockcond.And{
358+
mockcond.MethodPOST(),
359+
mockcond.Path("/crm/v3/objects/contacts/batch/update"),
360+
},
361+
Then: mockserver.Response(http.StatusOK, responseUpdateContacts),
338362
}.Server(),
339363
Comparator: testroutines.ComparatorSubsetBatchWrite,
340364
Expected: &common.BatchWriteResult{

0 commit comments

Comments
 (0)