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

Function TestCollectionsChangeConfigScope

rest/api_collections_test.go:604–673  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

602}
603
604func TestCollectionsChangeConfigScope(t *testing.T) {
605 if base.UnitTestUrlIsWalrus() {
606 t.Skip("can not create new buckets and scopes in walrus")
607 }
608
609 base.TestRequiresCollections(t)
610
611 ctx := base.TestCtx(t)
612 tb := base.GetTestBucket(t)
613 defer tb.Close(ctx)
614
615 scopesAndCollections := map[string][]string{
616 "fooScope": {
617 "bar",
618 },
619 "quxScope": {
620 "quux",
621 },
622 }
623 err := base.CreateBucketScopesAndCollections(ctx, tb.BucketSpec, scopesAndCollections)
624 require.NoError(t, err)
625 defer func() {
626 collection, err := base.AsCollection(tb.DefaultDataStore())
627 require.NoError(t, err)
628 cm := collection.Collection.Bucket().Collections()
629 for scope := range scopesAndCollections {
630 assert.NoError(t, cm.DropScope(scope, nil))
631 }
632
633 }()
634
635 rt := NewRestTester(t, &RestTesterConfig{
636 PersistentConfig: true,
637 CustomTestBucket: tb.NoCloseClone(),
638 })
639 defer rt.Close()
640
641 // Create a DB configured with one scope
642 res := rt.SendAdminRequest(http.MethodPut, "/db/", string(base.MustJSONMarshal(t, map[string]any{
643 "bucket": tb.GetName(),
644 "num_index_replicas": 0,
645 "enable_shared_bucket_access": base.TestUseXattrs(),
646 "use_views": base.TestsDisableGSI(),
647 "scopes": ScopesConfig{
648 "fooScope": {
649 Collections: CollectionsConfig{
650 "bar": {},
651 },
652 },
653 },
654 })))
655 RequireStatus(t, res, http.StatusCreated)
656
657 // Try updating its scopes
658 res = rt.SendAdminRequest(http.MethodPut, "/db/_config", string(base.MustJSONMarshal(t, map[string]any{
659 "bucket": tb.GetName(),
660 "num_index_replicas": 0,
661 "enable_shared_bucket_access": base.TestUseXattrs(),

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
SendAdminRequestMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
TestRequiresCollectionsFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
AsCollectionFunction · 0.92
MustJSONMarshalFunction · 0.92
TestUseXattrsFunction · 0.92
TestsDisableGSIFunction · 0.92
NewRestTesterFunction · 0.85

Tested by

no test coverage detected