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

Function TestDisableScopesInLegacyConfig

rest/server_context_test.go:761–815  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

759}
760
761func 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.
818func TestOfflineDatabaseStartup(t *testing.T) {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
PtrFunction · 0.92
ServerIsTLSFunction · 0.92
UnitTestUrlFunction · 0.92
TestTLSSkipVerifyFunction · 0.92
TestClusterUsernameFunction · 0.92
TestClusterPasswordFunction · 0.92
TestUseXattrsFunction · 0.92
TestsDisableGSIFunction · 0.92

Tested by

no test coverage detected