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

Function TestDevStore_SameMetaIsIdempotent

pkgcache/cache_dev_artifact_test.go:114–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestDevStore_SameMetaIsIdempotent(t *testing.T) {
115 cache := newTestDevArtifactCache(t)
116 pkgDir := makePackageDir(t, "glog@0.6.0")
117
118 const meta = "same-meta"
119 if err := cache.Store(pkgDir, meta); err != nil {
120 t.Fatal(err)
121 }
122 // Store again with identical meta → same hash, should overwrite not duplicate.
123 if err := cache.Store(pkgDir, meta); err != nil {
124 t.Fatal(err)
125 }
126
127 hash := computeHash(meta)
128 archivePath := filepath.Join(cache.cacheDir, "glog@0.6.0", hash+".tar.gz")
129 if !fileio.PathExists(archivePath) {
130 t.Errorf("archive should exist after idempotent store: %s", archivePath)
131 }
132
133 // Count .tar.gz files — should be exactly 1.
134 entries, err := os.ReadDir(filepath.Join(cache.cacheDir, "glog@0.6.0"))
135 if err != nil {
136 t.Fatal(err)
137 }
138 var count int
139 for _, e := range entries {
140 if e.Name() != "metas" && filepath.Ext(e.Name()) == ".gz" {
141 count++
142 }
143 }
144 if count != 1 {
145 t.Errorf("expected 1 archive after idempotent store, got %d", count)
146 }
147}
148
149func TestDevStore_PackageDirNotExist(t *testing.T) {
150 cache := newTestDevArtifactCache(t)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected