(t *testing.T)
| 602 | } |
| 603 | |
| 604 | func 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(), |
nothing calls this directly
no test coverage detected