aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/pkg_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-13 19:27:58 +0900
committerOphestra <cat@gensokyo.uk>2026-05-13 19:27:58 +0900
commit8c2dd3e9848799ac8408b8322e3eba237ce37903 (patch)
tree4161a57491a1b725420284cf14e7d97d69b6b2d6 /internal/pkg/pkg_test.go
parent67038d5af400254a1a47490c155eae97da7d7e95 (diff)
internal/pkg: verify status kind
While it is still impossible to reliably determine the expected contents of these status files, this checks their nature for expected substitution behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg_test.go')
-rw-r--r--internal/pkg/pkg_test.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go
index 48763b2a..0877e791 100644
--- a/internal/pkg/pkg_test.go
+++ b/internal/pkg/pkg_test.go
@@ -245,6 +245,30 @@ func newDestroyArtifactFunc(a pkg.Artifact) func(
}
}
+// destroyStatus counts non-substitution status entries and destroys them.
+func destroyStatus(t *testing.T, base *check.Absolute, n int) {
+ dents, err := os.ReadDir(base.Append("status").String())
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ for _, dent := range dents {
+ if !dent.Type().IsRegular() {
+ t.Errorf("%s: %s", dent.Name(), dent.Type())
+ }
+ if err = os.Remove(base.Append(
+ "status",
+ dent.Name(),
+ ).String()); err != nil {
+ t.Fatal(err)
+ }
+ }
+
+ if len(dents) != n {
+ t.Errorf("ReadDir: %d entries, want %d", len(dents), n)
+ }
+}
+
func TestIdent(t *testing.T) {
t.Parallel()
@@ -489,8 +513,9 @@ func checkWithCache(t *testing.T, testCases []cacheTestCase) {
}
}
- // destroy non-deterministic status files
- if err := os.RemoveAll(base.Append("status").String()); err != nil {
+ // destroy empty status directory
+ if err := syscall.Rmdir(base.Append("status").String()); err != nil {
+ t.Error(expectsFrom(base.Append("status").String()))
t.Fatal(err)
}