diff options
Diffstat (limited to 'internal/engine/roundtrip_test.go')
| -rw-r--r-- | internal/engine/roundtrip_test.go | 21 |
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") |
