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

Function TestViewQueryTombstoneRetrieval

rest/importtest/import_test.go:467–543  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

465}
466
467func TestViewQueryTombstoneRetrieval(t *testing.T) {
468 base.SkipImportTestsIfNotEnabled(t)
469
470 if !base.TestsDisableGSI() {
471 t.Skip("views tests are not applicable under GSI")
472 }
473
474 rtConfig := rest.RestTesterConfig{
475 SyncFn: `function(doc, oldDoc) { channel(doc.channels) }`,
476 DatabaseConfig: &rest.DatabaseConfig{DbConfig: rest.DbConfig{
477 AutoImport: false,
478 }},
479 }
480 rt := rest.NewRestTesterDefaultCollection(t, &rtConfig)
481 defer rt.Close()
482
483 dataStore := rt.GetSingleDataStore()
484
485 base.SetUpTestLogging(t, base.LevelDebug, base.KeyImport)
486
487 // 1. Create and import docs
488 key := "SG_delete"
489 docBody := make(map[string]interface{})
490 docBody["test"] = key
491 docBody["channels"] = "ABC"
492
493 response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/"+key, `{"channels":"ABC"}`)
494 assert.Equal(t, 201, response.Code)
495 log.Printf("insert response: %s", response.Body.Bytes())
496 var body db.Body
497 assert.NoError(t, base.JSONUnmarshal(response.Body.Bytes(), &body))
498 assert.Equal(t, true, body["ok"])
499 revId := body["rev"].(string)
500
501 sdk_key := "SDK_delete"
502 docBody = make(map[string]interface{})
503 docBody["test"] = sdk_key
504 docBody["channels"] = "ABC"
505
506 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/"+sdk_key, `{"channels":"ABC"}`)
507 assert.Equal(t, 201, response.Code)
508 log.Printf("insert response: %s", response.Body.Bytes())
509 assert.NoError(t, base.JSONUnmarshal(response.Body.Bytes(), &body))
510 assert.Equal(t, true, body["ok"])
511
512 // 2. Delete SDK_delete through the SDK
513 log.Printf("...............Delete through SDK.....................................")
514 deleteErr := dataStore.Delete(sdk_key)
515 assert.NoError(t, deleteErr, "Couldn't delete via SDK")
516
517 // Trigger import via SG retrieval
518 response = rt.SendAdminRequest("GET", "/{{.keyspace}}/"+sdk_key, "")
519 assert.Equal(t, 404, response.Code) // expect 404 deleted
520
521 // 3. Delete SG_delete through SG.
522 log.Printf("...............Delete through SG.......................................")
523 response = rt.SendAdminRequest("DELETE", fmt.Sprintf("/{{.keyspace}}/%s?rev=%s", key, revId), "")
524 assert.Equal(t, 200, response.Code)

Callers

nothing calls this directly

Calls 14

TestsDisableGSIFunction · 0.92
SetUpTestLoggingFunction · 0.92
JSONUnmarshalFunction · 0.92
SendAdminRequestMethod · 0.80
CloseMethod · 0.65
LenMethod · 0.65
GetSingleDataStoreMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected