TestRevisionCacheLoad Tests simple retrieval of rev not resident in the cache
(t *testing.T)
| 68 | // TestRevisionCacheLoad |
| 69 | // Tests simple retrieval of rev not resident in the cache |
| 70 | func TestRevisionCacheLoad(t *testing.T) { |
| 71 | |
| 72 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) |
| 73 | |
| 74 | db, ctx := setupTestDBWithViewsEnabled(t) |
| 75 | defer db.Close(ctx) |
| 76 | collection, ctx := GetSingleDatabaseCollectionWithUser(ctx, t, db) |
| 77 | |
| 78 | base.TestExternalRevStorage = true |
| 79 | |
| 80 | // Create rev 1-a |
| 81 | log.Printf("Create rev 1-a") |
| 82 | body := Body{"key1": "value1", "version": "1a"} |
| 83 | _, _, err := collection.PutExistingRevWithBody(ctx, "doc1", body, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV) |
| 84 | assert.NoError(t, err, "add 1-a") |
| 85 | |
| 86 | // Flush the cache |
| 87 | db.FlushRevisionCacheForTest() |
| 88 | |
| 89 | // Retrieve the document: |
| 90 | log.Printf("Retrieve doc 1-a...") |
| 91 | _, err = collection.Get1xRevBody(ctx, "doc1", "1-a", false, nil) |
| 92 | assert.NoError(t, err, "Couldn't get document") |
| 93 | |
| 94 | docRev, err := collection.GetRev(ctx, "doc1", "1-a", false, nil) |
| 95 | assert.NoError(t, err) |
| 96 | assert.Equal(t, "1-a", docRev.RevID) |
| 97 | |
| 98 | // Validate that mutations to the body don't affect the revcache value |
| 99 | _, err = base.InjectJSONProperties(docRev.BodyBytes, base.KVPair{Key: "modified", Val: "property"}) |
| 100 | assert.NoError(t, err) |
| 101 | |
| 102 | docRevAgain, err := collection.GetRev(ctx, "doc1", "1-a", false, nil) |
| 103 | assert.NoError(t, err) |
| 104 | assert.Equal(t, "1-a", docRevAgain.RevID) |
| 105 | |
| 106 | body, err = docRevAgain.Body() |
| 107 | assert.NoError(t, err) |
| 108 | _, ok := body["modified"] |
| 109 | assert.False(t, ok) |
| 110 | } |
| 111 | |
| 112 | func TestHasAttachmentsFlag(t *testing.T) { |
| 113 | base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) |
nothing calls this directly
no test coverage detected