From 49ea29a66254cc23265025a912a73c3e5b0c6ae5 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 21:46:08 +0200 Subject: plan 9: property test compares directories and refuses to pass vacuously; undo tracks directories trash restores recreate --- internal/engine/roundtrip_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/engine/roundtrip_test.go') 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") -- cgit v1.3