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

Function TestDevStore_ArchiveCreated

pkgcache/cache_dev_artifact_test.go:57–85  ·  view source on GitHub ↗

---- Store tests ----

(t *testing.T)

Source from the content-addressed store, hash-verified

55// ---- Store tests ----
56
57func TestDevStore_ArchiveCreated(t *testing.T) {
58 cache := newTestDevArtifactCache(t)
59 pkgDir := makePackageDir(t, "gflags@2.2.2")
60
61 const meta = "test-meta-content"
62 if err := cache.Store(pkgDir, meta); err != nil {
63 t.Fatalf("Store failed: %v", err)
64 }
65
66 hash := computeHash(meta)
67 archivePath := filepath.Join(cache.cacheDir, "gflags@2.2.2", hash+".tar.gz")
68 metaPath := filepath.Join(cache.cacheDir, "gflags@2.2.2", "metas", hash+".meta")
69
70 if !fileio.PathExists(archivePath) {
71 t.Errorf("archive not created at %s", archivePath)
72 }
73 if !fileio.PathExists(metaPath) {
74 t.Errorf("meta file not created at %s", metaPath)
75 }
76
77 // Meta content should match what was passed in.
78 got, err := os.ReadFile(metaPath)
79 if err != nil {
80 t.Fatal(err)
81 }
82 if string(got) != meta {
83 t.Errorf("meta content = %q, want %q", got, meta)
84 }
85}
86
87func TestDevStore_DifferentMetaProducesDifferentHash(t *testing.T) {
88 cache := newTestDevArtifactCache(t)

Callers

nothing calls this directly

Calls 5

PathExistsFunction · 0.92
newTestDevArtifactCacheFunction · 0.85
makePackageDirFunction · 0.85
computeHashFunction · 0.85
StoreMethod · 0.65

Tested by

no test coverage detected