(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func 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 | |
| 171 | func TestUnmarshalBrokenConfig(t *testing.T) { |
| 172 | t.Skip("Disabled, CBG-2420") |
nothing calls this directly
no test coverage detected