(t *testing.T)
| 759 | } |
| 760 | |
| 761 | func TestDisableScopesInLegacyConfig(t *testing.T) { |
| 762 | ctx := base.TestCtx(t) |
| 763 | bucket := base.GetTestBucket(t) |
| 764 | defer bucket.Close(ctx) |
| 765 | |
| 766 | for _, persistentConfig := range []bool{false, true} { |
| 767 | for _, scopes := range []bool{false, true} { |
| 768 | t.Run(fmt.Sprintf("persistent_config=%t", persistentConfig), func(t *testing.T) { |
| 769 | |
| 770 | ctx := base.TestCtx(t) |
| 771 | startupConfig := &StartupConfig{ |
| 772 | Bootstrap: BootstrapConfig{ |
| 773 | UseTLSServer: base.Ptr(base.ServerIsTLS(base.UnitTestUrl())), |
| 774 | ServerTLSSkipVerify: base.Ptr(base.TestTLSSkipVerify()), |
| 775 | }, |
| 776 | } |
| 777 | |
| 778 | serverContext := NewServerContext(ctx, startupConfig, persistentConfig) |
| 779 | defer serverContext.Close(ctx) |
| 780 | |
| 781 | dbConfig := DbConfig{ |
| 782 | Name: "db", |
| 783 | BucketConfig: BucketConfig{ |
| 784 | Server: base.Ptr(base.UnitTestUrl()), |
| 785 | Bucket: base.Ptr(bucket.GetName()), |
| 786 | Username: base.TestClusterUsername(), |
| 787 | Password: base.TestClusterPassword(), |
| 788 | }, |
| 789 | EnableXattrs: base.Ptr(base.TestUseXattrs()), |
| 790 | UseViews: base.Ptr(base.TestsDisableGSI()), |
| 791 | } |
| 792 | if scopes { |
| 793 | if !base.TestsUseNamedCollections() { |
| 794 | t.Skip("can not run collections tests in non collections configuration") |
| 795 | } |
| 796 | dbConfig.Scopes = GetCollectionsConfig(t, bucket, 1) |
| 797 | } |
| 798 | dbContext, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, |
| 799 | getOrAddDatabaseConfigOptions{ |
| 800 | failFast: false, |
| 801 | useExisting: false, |
| 802 | }) |
| 803 | if persistentConfig || scopes == false { |
| 804 | require.NoError(t, err) |
| 805 | require.NotNil(t, dbContext) |
| 806 | return |
| 807 | } |
| 808 | require.Nil(t, dbContext) |
| 809 | require.Error(t, err) |
| 810 | require.Contains(t, err.Error(), strconv.Itoa(http.StatusBadRequest)) |
| 811 | require.Contains(t, err.Error(), "legacy config") |
| 812 | }) |
| 813 | } |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | // TestOfflineDatabaseStartup ensures that background processes are not actually running when starting up a database in offline mode. |
| 818 | func TestOfflineDatabaseStartup(t *testing.T) { |
nothing calls this directly
no test coverage detected