MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestRestore_ArchiveCorrectness

Function TestRestore_ArchiveCorrectness

pkgcache/cache_repo_test.go:284–313  ·  view source on GitHub ↗

---- Restore tests ----

(t *testing.T)

Source from the content-addressed store, hash-verified

282// ---- Restore tests ----
283
284func TestRestore_ArchiveCorrectness(t *testing.T) {
285 tmpDir, pkgCacheDir, _ := setupTestEnv(t)
286 rc := newRepoConfig(pkgCacheDir, true)
287
288 archivePath, checksum := createArchiveFlat(t, tmpDir, "hello.txt", "hello-from-archive")
289 repoDir := filepath.Join(tmpDir, "buildtrees", "x264@stable", "src")
290 repoURL := "https://example.com/lib.tar.gz"
291
292 // Store first.
293 if _, err := rc.Store("x264@stable", repoURL, repoDir, archivePath); err != nil {
294 t.Fatal(err)
295 }
296
297 // Restore into a clean dir.
298 restored, err := rc.Restore("x264@stable", repoURL, repoDir, checksum)
299 if err != nil {
300 t.Fatal(err)
301 }
302 if restored == "" {
303 t.Fatal("expected non-empty restored path")
304 }
305
306 content, err := os.ReadFile(filepath.Join(repoDir, "hello.txt"))
307 if err != nil {
308 t.Fatal(err)
309 }
310 if string(content) != "hello-from-archive" {
311 t.Fatalf("unexpected restored content: %q", string(content))
312 }
313}
314
315func TestRestore_ArchiveFlattensNestedDir(t *testing.T) {
316 tmpDir, pkgCacheDir, _ := setupTestEnv(t)

Callers

nothing calls this directly

Calls 5

setupTestEnvFunction · 0.85
newRepoConfigFunction · 0.85
createArchiveFlatFunction · 0.85
StoreMethod · 0.65
RestoreMethod · 0.65

Tested by

no test coverage detected