(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func 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 | |
| 149 | func TestDevStore_PackageDirNotExist(t *testing.T) { |
| 150 | cache := newTestDevArtifactCache(t) |
nothing calls this directly
no test coverage detected