MCPcopy Index your code
hub / github.com/celer-pkg/celer / TestDevRestore_CacheHit

Function TestDevRestore_CacheHit

pkgcache/cache_dev_artifact_test.go:172–204  ·  view source on GitHub ↗

---- Restore tests ----

(t *testing.T)

Source from the content-addressed store, hash-verified

170// ---- Restore tests ----
171
172func TestDevRestore_CacheHit(t *testing.T) {
173 cache := newTestDevArtifactCache(t)
174 pkgDir := makePackageDir(t, "gflags@2.2.2")
175
176 const meta = "restore-meta"
177 if err := cache.Store(pkgDir, meta); err != nil {
178 t.Fatal(err)
179 }
180 hash := computeHash(meta)
181
182 // Remove the original package dir, then Restore should recreate it.
183 if err := os.RemoveAll(pkgDir); err != nil {
184 t.Fatal(err)
185 }
186
187 // Restore to a fresh location (simulating a new workspace).
188 destDir := filepath.Join(t.TempDir(), "restored", "gflags@2.2.2")
189 fromPath, err := cache.Restore("gflags@2.2.2", hash, destDir)
190 if err != nil {
191 t.Fatalf("Restore failed: %v", err)
192 }
193 if fromPath == "" {
194 t.Fatal("expected cache hit, got empty path")
195 }
196
197 // Verify restored files exist.
198 if !fileio.PathExists(filepath.Join(destDir, "libfoo.a")) {
199 t.Error("libfoo.a should be restored")
200 }
201 if !fileio.PathExists(filepath.Join(destDir, "include", "foo.h")) {
202 t.Error("include/foo.h should be restored")
203 }
204}
205
206func TestDevRestore_CacheMiss(t *testing.T) {
207 cache := newTestDevArtifactCache(t)

Callers

nothing calls this directly

Calls 7

PathExistsFunction · 0.92
newTestDevArtifactCacheFunction · 0.85
makePackageDirFunction · 0.85
computeHashFunction · 0.85
ErrorMethod · 0.80
StoreMethod · 0.65
RestoreMethod · 0.65

Tested by

no test coverage detected