diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-05 22:54:16 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-05 22:54:16 +0900 |
| commit | 3d4d32932df47816be751062f2f9e77cc38d0148 (patch) | |
| tree | 2c018bafc556d7d9350e56bbc061b65a9e4b4bbd /internal | |
| parent | 0ab6c13c77d36445b656c0f53c008c7cb7376bca (diff) | |
internal/pkg: verify checksum after uneventful scrub
This checks that scrub did not condemn any entry without reporting it.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/pkg/pkg_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index 2f5cc424..8826e5a1 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -202,6 +202,15 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) { scrubFunc = c.Scrub } + var restoreTemp bool + if _, err := os.Lstat(base.Append("temp").String()); err != nil { + if !errors.Is(err, os.ErrNotExist) { + t.Fatal(err) + } + } else { + restoreTemp = true + } + if checksum, err := pkg.HashDir(base); err != nil { t.Fatalf("HashDir: error = %v", err) } else if checksum != tc.want { @@ -214,6 +223,25 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) { if err := scrubFunc(); err != nil { t.Fatal("cache contains inconsistencies\n\n" + err.Error()) } + + if restoreTemp { + if err := os.Mkdir( + base.Append("temp").String(), + 0700, + ); err != nil { + t.Fatal(err) + } + } + + // validate again to make sure scrub did not condemn anything + if checksum, err := pkg.HashDir(base); err != nil { + t.Fatalf("HashDir: error = %v", err) + } else if checksum != tc.want { + t.Fatalf("(scrubbed) HashDir: %v", &pkg.ChecksumMismatchError{ + Got: checksum, + Want: tc.want, + }) + } }) } } |
