MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestUtilitiesProposeChangesBatch

Function TestUtilitiesProposeChangesBatch

rest/utilities_testing_test.go:337–401  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

335}
336
337func TestUtilitiesProposeChangesBatch(t *testing.T) {
338 // Currently proposeChanges sends the full history to match the Couchbase Lite 4.0.0 implementation. When CBL
339 // implements CBL-4433 and only sends CV, it would be OK to remove this test.
340 testCases := []struct {
341 name string
342 entry proposeChangeBatchEntry
343 // expected can be one of multiple valid values, since the order of the HLV versions is not guaranteed
344 expected []string
345 }{
346 {
347 name: "cv,mv",
348 entry: proposeChangeBatchEntry{
349 docID: "doc1",
350 version: DocVersion{
351 CV: db.Version{SourceID: "cbl1", Value: 2},
352 },
353 hlvHistory: db.HybridLogicalVector{
354 Version: 2,
355 SourceID: "cbl1",
356 MergeVersions: db.HLVVersions{
357 "rosmar1": 1,
358 "rosmar2": 2,
359 },
360 },
361 latestServerVersion: DocVersion{
362 CV: db.Version{SourceID: "rosmar1", Value: 1},
363 },
364 },
365 expected: []string{
366 `["doc1","2@cbl1,2@rosmar2,1@rosmar1;","1@rosmar1"]`,
367 `["doc1","2@cbl1,1@rosmar1,2@rosmar2;","1@rosmar1"]`,
368 },
369 },
370 {
371 name: "cv,pv",
372 entry: proposeChangeBatchEntry{
373 docID: "doc1",
374 version: DocVersion{
375 CV: db.Version{SourceID: "cbl1", Value: 4},
376 },
377 hlvHistory: db.HybridLogicalVector{
378 Version: 4,
379 SourceID: "cbl1",
380 PreviousVersions: db.HLVVersions{
381 "rosmar1": 3,
382 "rosmar2": 2,
383 },
384 },
385 latestServerVersion: DocVersion{
386 CV: db.Version{SourceID: "rosmar1", Value: 1},
387 },
388 },
389 expected: []string{
390 `["doc1","4@cbl1;2@rosmar2,3@rosmar1","1@rosmar1"]`,
391 `["doc1","4@cbl1;3@rosmar1,2@rosmar2","1@rosmar1"]`,
392 },
393 },
394 }

Callers

nothing calls this directly

Calls 3

MustJSONMarshalFunction · 0.92
RunMethod · 0.65
ContainsMethod · 0.65

Tested by

no test coverage detected