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

Function TestBootstrapDuplicateCollections

rest/bootstrap_test.go:119–146  ·  view source on GitHub ↗

TestBootstrapDuplicateBucket will attempt to create two databases sharing the same collections and ensure this isn't allowed.

(t *testing.T)

Source from the content-addressed store, hash-verified

117
118// TestBootstrapDuplicateBucket will attempt to create two databases sharing the same collections and ensure this isn't allowed.
119func TestBootstrapDuplicateCollections(t *testing.T) {
120 base.SetUpTestLogging(t, base.LevelInfo, base.KeyHTTP)
121
122 sc, closeFn := StartBootstrapServer(t)
123 defer closeFn()
124
125 ctx := base.TestCtx(t)
126
127 // Get a test bucket, and use it to create the database.
128 tb := base.GetTestBucket(t)
129 defer tb.Close(ctx)
130 resp := BootstrapAdminRequest(t, sc, http.MethodPut, "/db1/",
131 fmt.Sprintf(
132 `{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "use_views": %t}`,
133 tb.GetName(), base.TestUseXattrs(), base.TestsDisableGSI(),
134 ),
135 )
136 resp.RequireStatus(http.StatusCreated)
137
138 // Create db2 using the same collection (on the same bucket) and expect it to fail
139 resp = BootstrapAdminRequest(t, sc, http.MethodPut, "/db2/",
140 fmt.Sprintf(
141 `{"bucket": "%s", "num_index_replicas": 0, "enable_shared_bucket_access": %t, "use_views": %t}`,
142 tb.GetName(), base.TestUseXattrs(), base.TestsDisableGSI(),
143 ),
144 )
145 resp.RequireStatus(http.StatusConflict)
146}
147
148// TestBootstrapDuplicateDatabase will attempt to create a second database and ensure this isn't allowed.
149func TestBootstrapDuplicateDatabase(t *testing.T) {

Callers

nothing calls this directly

Calls 10

SetUpTestLoggingFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
TestUseXattrsFunction · 0.92
TestsDisableGSIFunction · 0.92
StartBootstrapServerFunction · 0.85
BootstrapAdminRequestFunction · 0.85
RequireStatusMethod · 0.80
CloseMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected