MCPcopy
hub / github.com/apptainer/apptainer / prepTest

Function prepTest

e2e/cache/cache.go:35–60  ·  view source on GitHub ↗
(t *testing.T, testEnv e2e.TestEnv, testName string, cacheParentDir string, imagePath string)

Source from the content-addressed store, hash-verified

33const imgName = "alpine_latest.sif"
34
35func 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
62func (c cacheTests) testNoninteractiveCacheCmds(t *testing.T) {
63 tests := []struct {

Callers 2

Calls 8

IsFileFunction · 0.92
WithProfileFunction · 0.92
WithCommandFunction · 0.92
WithArgsFunction · 0.92
ExpectExitFunction · 0.92
ensureNotCachedFunction · 0.85
ensureCachedFunction · 0.85
RunApptainerMethod · 0.80

Tested by

no test coverage detected