---- Store tests ----
(t *testing.T)
| 55 | // ---- Store tests ---- |
| 56 | |
| 57 | func 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 | |
| 87 | func TestDevStore_DifferentMetaProducesDifferentHash(t *testing.T) { |
| 88 | cache := newTestDevArtifactCache(t) |
nothing calls this directly
no test coverage detected