---- Restore tests ----
(t *testing.T)
| 170 | // ---- Restore tests ---- |
| 171 | |
| 172 | func TestDevRestore_CacheHit(t *testing.T) { |
| 173 | cache := newTestDevArtifactCache(t) |
| 174 | pkgDir := makePackageDir(t, "gflags@2.2.2") |
| 175 | |
| 176 | const meta = "restore-meta" |
| 177 | if err := cache.Store(pkgDir, meta); err != nil { |
| 178 | t.Fatal(err) |
| 179 | } |
| 180 | hash := computeHash(meta) |
| 181 | |
| 182 | // Remove the original package dir, then Restore should recreate it. |
| 183 | if err := os.RemoveAll(pkgDir); err != nil { |
| 184 | t.Fatal(err) |
| 185 | } |
| 186 | |
| 187 | // Restore to a fresh location (simulating a new workspace). |
| 188 | destDir := filepath.Join(t.TempDir(), "restored", "gflags@2.2.2") |
| 189 | fromPath, err := cache.Restore("gflags@2.2.2", hash, destDir) |
| 190 | if err != nil { |
| 191 | t.Fatalf("Restore failed: %v", err) |
| 192 | } |
| 193 | if fromPath == "" { |
| 194 | t.Fatal("expected cache hit, got empty path") |
| 195 | } |
| 196 | |
| 197 | // Verify restored files exist. |
| 198 | if !fileio.PathExists(filepath.Join(destDir, "libfoo.a")) { |
| 199 | t.Error("libfoo.a should be restored") |
| 200 | } |
| 201 | if !fileio.PathExists(filepath.Join(destDir, "include", "foo.h")) { |
| 202 | t.Error("include/foo.h should be restored") |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | func TestDevRestore_CacheMiss(t *testing.T) { |
| 207 | cache := newTestDevArtifactCache(t) |
nothing calls this directly
no test coverage detected