---- Restore tests ----
(t *testing.T)
| 282 | // ---- Restore tests ---- |
| 283 | |
| 284 | func 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 | |
| 315 | func TestRestore_ArchiveFlattensNestedDir(t *testing.T) { |
| 316 | tmpDir, pkgCacheDir, _ := setupTestEnv(t) |
nothing calls this directly
no test coverage detected