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

Function TestRevAndVersion

db/document_test.go:308–384  ·  view source on GitHub ↗

TestRevAndVersion tests marshalling and unmarshalling rev and current version

(t *testing.T)

Source from the content-addressed store, hash-verified

306
307// TestRevAndVersion tests marshalling and unmarshalling rev and current version
308func TestRevAndVersion(t *testing.T) {
309
310 ctx := base.TestCtx(t)
311 testCases := []struct {
312 testName string
313 revTreeID string
314 source string
315 version string
316 }{
317 {
318 testName: "rev_and_version",
319 revTreeID: "1-abc",
320 source: "source1",
321 version: "0x0100000000000000",
322 },
323 {
324 testName: "both_empty",
325 revTreeID: "",
326 source: "",
327 version: "0",
328 },
329 {
330 testName: "revTreeID_only",
331 revTreeID: "1-abc",
332 source: "",
333 version: "0",
334 },
335 {
336 testName: "currentVersion_only",
337 revTreeID: "",
338 source: "source1",
339 version: "0x0100000000000000",
340 },
341 }
342
343 var expectedSequence = uint64(100)
344 for _, test := range testCases {
345 t.Run(test.testName, func(t *testing.T) {
346 syncData := &SyncData{
347 RevAndVersion: channels.RevAndVersion{
348 RevTreeID: test.revTreeID,
349 CurrentSource: test.source,
350 CurrentVersion: test.version,
351 },
352 Sequence: expectedSequence,
353 }
354 // SyncData test
355 marshalledSyncData, err := base.JSONMarshal(syncData)
356 require.NoError(t, err)
357 log.Printf("marshalled:%s", marshalledSyncData)
358
359 // Document test
360 document := NewDocument("docID")
361 document.SetRevTreeID(test.revTreeID)
362 document.SyncData.Sequence = expectedSequence
363 document.HLV = &HybridLogicalVector{
364 SourceID: test.source,
365 Version: base.HexCasToUint64(test.version),

Callers

nothing calls this directly

Calls 10

MarshalWithXattrsMethod · 0.95
UnmarshalWithXattrsMethod · 0.95
TestCtxFunction · 0.92
JSONMarshalFunction · 0.92
HexCasToUint64Function · 0.92
NewDocumentFunction · 0.85
SetRevTreeIDMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.45
GetRevTreeIDMethod · 0.45

Tested by

no test coverage detected