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

Function TestAutomaticConfigUpgradeError

rest/persistent_config_test.go:118–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestAutomaticConfigUpgradeError(t *testing.T) {
119 if base.UnitTestUrlIsWalrus() {
120 t.Skip("CBS required")
121 }
122
123 testCases := []struct {
124 Name string
125 Config string
126 }{
127 {
128 "Multiple DBs different servers",
129 `
130 {
131 "server_tls_skip_verify": %t,
132 "databases": {
133 "db": {
134 "server": "%s",
135 "username": "%s",
136 "password": "%s",
137 "bucket": "%s"
138 },
139 "db2": {
140 "server": "rand",
141 "username": "",
142 "password": "",
143 "bucket": ""
144 }
145 }
146 }`,
147 },
148 }
149
150 for _, testCase := range testCases {
151 // Create tempdir here to avoid slash operator in t.Name()
152 tmpDir := t.TempDir()
153
154 t.Run(testCase.Name, func(t *testing.T) {
155 ctx := base.TestCtx(t)
156 tb := base.GetTestBucket(t)
157 defer tb.Close(ctx)
158
159 config := fmt.Sprintf(testCase.Config, base.TestTLSSkipVerify(), base.UnitTestUrl(), base.TestClusterUsername(), base.TestClusterPassword(), tb.GetName())
160
161 configPath := filepath.Join(tmpDir, "config.json")
162 err := os.WriteFile(configPath, []byte(config), os.FileMode(0644))
163 require.NoError(t, err)
164
165 _, _, _, _, err = automaticConfigUpgrade(base.TestCtx(t), configPath)
166 assert.Error(t, err)
167 })
168 }
169}
170
171func TestUnmarshalBrokenConfig(t *testing.T) {
172 t.Skip("Disabled, CBG-2420")

Callers

nothing calls this directly

Calls 12

UnitTestUrlIsWalrusFunction · 0.92
TestCtxFunction · 0.92
GetTestBucketFunction · 0.92
TestTLSSkipVerifyFunction · 0.92
UnitTestUrlFunction · 0.92
TestClusterUsernameFunction · 0.92
TestClusterPasswordFunction · 0.92
automaticConfigUpgradeFunction · 0.85
RunMethod · 0.65
CloseMethod · 0.65
GetNameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected