aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/roundtrip_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 21:46:08 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 21:46:08 +0200
commit49ea29a66254cc23265025a912a73c3e5b0c6ae5 (patch)
treead2a9003da778add4565c46a6641a3987d4a7ce2 /internal/engine/roundtrip_test.go
parentc497d173b24b1b8247fac9e996e5c0fe690c1769 (diff)
downloadkrino-49ea29a66254cc23265025a912a73c3e5b0c6ae5.tar.gz
krino-49ea29a66254cc23265025a912a73c3e5b0c6ae5.zip
plan 9: property test compares directories and refuses to pass vacuously; undo tracks directories trash restores recreate
Diffstat (limited to 'internal/engine/roundtrip_test.go')
-rw-r--r--internal/engine/roundtrip_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/engine/roundtrip_test.go b/internal/engine/roundtrip_test.go
index 67de507..e54b0b7 100644
--- a/internal/engine/roundtrip_test.go
+++ b/internal/engine/roundtrip_test.go
@@ -44,6 +44,27 @@ func snapshot(t *testing.T, root string) map[string]string {
return out
}
+// treeSnapshot is snapshot plus one "dir" entry per directory under root,
+// so a comparison also sees directories left behind or missing.
+func treeSnapshot(t *testing.T, root string) map[string]string {
+ t.Helper()
+ out := snapshot(t, root)
+ err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error {
+ if err != nil {
+ return err
+ }
+ if d.IsDir() && p != root {
+ rel, _ := filepath.Rel(root, p)
+ out[rel+"/"] = "dir"
+ }
+ return nil
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ return out
+}
+
func TestApplyThenUndoRestoresTheTree(t *testing.T) {
h := sandbox(t)
dl := filepath.Join(h, "dl")