TestCheckProposedVersionWithHLVRev tests CheckProposedVersion when the full HLV is provided in the rev element of the proposeChanges message
(t *testing.T)
| 447 | |
| 448 | // TestCheckProposedVersionWithHLVRev tests CheckProposedVersion when the full HLV is provided in the rev element of the proposeChanges message |
| 449 | func TestCheckProposedVersionWithHLVRev(t *testing.T) { |
| 450 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll) |
| 451 | |
| 452 | db, ctx := setupTestDB(t) |
| 453 | defer db.Close(ctx) |
| 454 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 455 | |
| 456 | // create singleVersionDoc with cv:1000@abc |
| 457 | body := Body{"key1": "value1", "key2": 1234} |
| 458 | singleVersionDoc := collection.UpsertTestDocWithVersion(ctx, t, "singleVersionDoc", body, "1000@abc", "") |
| 459 | require.NotNil(t, singleVersionDoc) |
| 460 | log.Printf("created singleVersionDoc doc successfully with HLV: %#v", singleVersionDoc.HLV) |
| 461 | |
| 462 | // create multiVersionDoc with cv:1000@abc, pv:900@def |
| 463 | collection.UpsertTestDocWithVersion(ctx, t, "multiVersionDoc", body, "900@def", "") |
| 464 | multiVersionDoc := collection.UpsertTestDocWithVersion(ctx, t, "multiVersionDoc", body, "1000@abc", "") |
| 465 | require.NotNil(t, multiVersionDoc) |
| 466 | log.Printf("created multiVersionDoc doc successfully with HLV: %#v", multiVersionDoc.HLV) |
| 467 | |
| 468 | // create multiVersionDoc with cv:1000@abc, mv:900@abc, 900@def, pv:900@ghi |
| 469 | collection.UpsertTestDocWithVersion(ctx, t, "mergeVersionDoc", body, "900@ghi", "") |
| 470 | docWithMV := collection.UpsertTestDocWithVersion(ctx, t, "mergeVersionDoc", body, "1000@abc", "900@abc, 900@def") |
| 471 | require.NotNil(t, docWithMV) |
| 472 | log.Printf("created mergeVersionDoc doc successfully with HLV: %#v", docWithMV.HLV) |
| 473 | |
| 474 | testCases := []struct { |
| 475 | name string // test name |
| 476 | key string |
| 477 | proposedVersion string // proposed version in CBL string format |
| 478 | previousRev string // previous revisions in CBL string format |
| 479 | proposedHLV string // proposed HLV in CBL string format |
| 480 | expectedStatus ProposedRevStatus // Expected status from CheckProposedVersion call |
| 481 | expectedRev string // Expected rev from CheckProposedVersion call (for conflict cases) |
| 482 | }{ |
| 483 | /* |
| 484 | Tests for existing doc with cv only (1000@abc) |
| 485 | */ |
| 486 | { |
| 487 | // already known, matches version |
| 488 | name: "exists same version", |
| 489 | key: "singleVersionDoc", |
| 490 | proposedVersion: "1000@abc", |
| 491 | previousRev: "", |
| 492 | proposedHLV: "1000@abc", |
| 493 | expectedStatus: ProposedRev_Exists, |
| 494 | expectedRev: "", |
| 495 | }, |
| 496 | { |
| 497 | // already known, older version |
| 498 | name: "exists older version", |
| 499 | key: "singleVersionDoc", |
| 500 | proposedVersion: "900@abc", |
| 501 | previousRev: "", |
| 502 | proposedHLV: "1000@abc", |
| 503 | expectedStatus: ProposedRev_Exists, |
| 504 | expectedRev: "", |
| 505 | }, |
| 506 | { |
nothing calls this directly
no test coverage detected