(t *testing.T, testEnv e2e.TestEnv, testName string, cacheParentDir string, imagePath string)
| 33 | const imgName = "alpine_latest.sif" |
| 34 | |
| 35 | func prepTest(t *testing.T, testEnv e2e.TestEnv, testName string, cacheParentDir string, imagePath string) (imageURL string, cleanup func()) { |
| 36 | // We will pull images from a temporary http server |
| 37 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 38 | http.ServeFile(w, r, testEnv.ImagePath) |
| 39 | })) |
| 40 | cleanup = srv.Close |
| 41 | |
| 42 | // If the test imageFile is already present check it's not also in the cache |
| 43 | // at the start of our test - we expect to pull it again and then see it |
| 44 | // appear in the cache. |
| 45 | if fs.IsFile(imagePath) { |
| 46 | ensureNotCached(t, testName, srv.URL, cacheParentDir) |
| 47 | } |
| 48 | |
| 49 | testEnv.UnprivCacheDir = cacheParentDir |
| 50 | testEnv.RunApptainer( |
| 51 | t, |
| 52 | e2e.WithProfile(e2e.UserProfile), |
| 53 | e2e.WithCommand("pull"), |
| 54 | e2e.WithArgs([]string{"--force", imagePath, srv.URL}...), |
| 55 | e2e.ExpectExit(0), |
| 56 | ) |
| 57 | |
| 58 | ensureCached(t, testName, srv.URL, cacheParentDir) |
| 59 | return srv.URL, cleanup |
| 60 | } |
| 61 | |
| 62 | func (c cacheTests) testNoninteractiveCacheCmds(t *testing.T) { |
| 63 | tests := []struct { |
no test coverage detected