(t *testing.T)
| 229 | } |
| 230 | |
| 231 | func TestRemote_SShGitHub_WithDisableCacheKey(t *testing.T) { |
| 232 | cleanfs := map[string]string{ |
| 233 | CacheDir(): "", |
| 234 | } |
| 235 | cachefs := map[string]string{ |
| 236 | filepath.Join(CacheDir(), "ssh_github_com_helmfile_helmfiles_git.ref=main/releases/kiam.yaml"): "foo: bar", |
| 237 | } |
| 238 | |
| 239 | testcases := []struct { |
| 240 | name string |
| 241 | files map[string]string |
| 242 | expectCacheHit bool |
| 243 | }{ |
| 244 | {name: "not expectCacheHit", files: cleanfs, expectCacheHit: false}, |
| 245 | {name: "forceNoCacheHit", files: cachefs, expectCacheHit: false}, |
| 246 | } |
| 247 | |
| 248 | for _, tt := range testcases { |
| 249 | t.Run(tt.name, func(t *testing.T) { |
| 250 | testfs := testhelper.NewTestFs(tt.files) |
| 251 | |
| 252 | hit := true |
| 253 | |
| 254 | get := func(wd, src, dst string) error { |
| 255 | if wd != CacheDir() { |
| 256 | return fmt.Errorf("unexpected wd: %s", wd) |
| 257 | } |
| 258 | if src != "git::ssh://git@github.com/helmfile/helmfiles.git?ref=main" { |
| 259 | return fmt.Errorf("unexpected src: %s", src) |
| 260 | } |
| 261 | |
| 262 | hit = false |
| 263 | |
| 264 | return nil |
| 265 | } |
| 266 | |
| 267 | getter := &testGetter{ |
| 268 | get: get, |
| 269 | } |
| 270 | remote := &Remote{ |
| 271 | Logger: helmexec.NewLogger(io.Discard, "debug"), |
| 272 | Home: CacheDir(), |
| 273 | Getter: getter, |
| 274 | fs: testfs.ToFileSystem(), |
| 275 | } |
| 276 | |
| 277 | url := "git::ssh://git@github.com/helmfile/helmfiles.git@releases/kiam.yaml?ref=main&cache=false" |
| 278 | file, err := remote.Locate(url) |
| 279 | if err != nil { |
| 280 | t.Fatalf("unexpected error: %v", err) |
| 281 | } |
| 282 | |
| 283 | expectedFile := filepath.Join(CacheDir(), "ssh_github_com_helmfile_helmfiles_git.ref=main/releases/kiam.yaml") |
| 284 | if file != expectedFile { |
| 285 | t.Errorf("unexpected file located: %s vs expected: %s", file, expectedFile) |
| 286 | } |
| 287 | |
| 288 | if tt.expectCacheHit && !hit { |
nothing calls this directly
no test coverage detected