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

Function TestStore_ArchiveCopiesOriginal

pkgcache/cache_repo_test.go:179–203  ·  view source on GitHub ↗

---- Store tests ----

(t *testing.T)

Source from the content-addressed store, hash-verified

177// ---- Store tests ----
178
179func 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
205func TestStore_ArchiveIdempotent(t *testing.T) {
206 tmpDir, pkgCacheDir, _ := setupTestEnv(t)

Callers

nothing calls this directly

Calls 5

ComputeSHA256Function · 0.92
setupTestEnvFunction · 0.85
newRepoConfigFunction · 0.85
createArchiveFlatFunction · 0.85
StoreMethod · 0.65

Tested by

no test coverage detected