---- Store tests ----
(t *testing.T)
| 177 | // ---- Store tests ---- |
| 178 | |
| 179 | func TestStore_ArchiveCopiesOriginal(t *testing.T) { |
| 180 | tmpDir, pkgCacheDir, _ := setupTestEnv(t) |
| 181 | rc := newRepoConfig(pkgCacheDir, true) |
| 182 | |
| 183 | archivePath, checksum := createArchiveFlat(t, tmpDir, "hello.txt", "hello") |
| 184 | repoDir := filepath.Join(tmpDir, "buildtrees", "x264@stable", "src") |
| 185 | |
| 186 | stored, err := rc.Store("x264@stable", "https://example.com/lib.tar.gz", repoDir, archivePath) |
| 187 | if err != nil { |
| 188 | t.Fatal(err) |
| 189 | } |
| 190 | |
| 191 | // Stored path should use the original extension. |
| 192 | expected := filepath.Join(pkgCacheDir, "repos", "x264@stable", checksum+".tar.gz") |
| 193 | if stored != expected { |
| 194 | t.Fatalf("expected stored path %s, got %s", expected, stored) |
| 195 | } |
| 196 | |
| 197 | // The cached file should be a byte-for-byte copy of the original. |
| 198 | origSHA, _ := fileio.ComputeSHA256(archivePath) |
| 199 | cachedSHA, _ := fileio.ComputeSHA256(stored) |
| 200 | if origSHA != cachedSHA { |
| 201 | t.Fatalf("cached archive SHA256 mismatch: orig %s, cached %s", origSHA, cachedSHA) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | func TestStore_ArchiveIdempotent(t *testing.T) { |
| 206 | tmpDir, pkgCacheDir, _ := setupTestEnv(t) |
nothing calls this directly
no test coverage detected