aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/roundtrip_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 20:16:38 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 20:16:38 +0200
commit7b2c020a08b3b9f291ba14c71b5fbb5693b6cf6f (patch)
tree51dd0d05a7a7d14bcf344adf67bc418d061e92c2 /internal/engine/roundtrip_test.go
parent754f362da077b06420ab8350dfb62bd2d8d89d75 (diff)
downloadkrino-7b2c020a08b3b9f291ba14c71b5fbb5693b6cf6f.tar.gz
krino-7b2c020a08b3b9f291ba14c71b5fbb5693b6cf6f.zip
plan 8: generated apply and undo round trip; undo reverses chains within one file
Diffstat (limited to 'internal/engine/roundtrip_test.go')
-rw-r--r--internal/engine/roundtrip_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/engine/roundtrip_test.go b/internal/engine/roundtrip_test.go
index 425dc1a..67de507 100644
--- a/internal/engine/roundtrip_test.go
+++ b/internal/engine/roundtrip_test.go
@@ -159,3 +159,21 @@ func TestApplyThenUndoRestoresTheTree(t *testing.T) {
t.Errorf("reading backup dir after undo: %v", err)
}
}
+
+// TestUndoReversesChainsWithinOneFile is the property test's first finding
+// (plan 8, Task 9): undo judged each move and rename against the disk as it
+// is now, so the first step of a chain - a rename then a move, two moves, a
+// move then trash - found its destination empty, because the later step had
+// already moved the file on, and the whole file was refused.
+func TestUndoReversesChainsWithinOneFile(t *testing.T) {
+ for name, rule := range map[string]string{
+ "rename then move": `(rule "r" (rename "r-{name}") (move "Out"))`,
+ "move then move": `(rule "r" (move "Out") (move "Out/{mtime:%Y}"))`,
+ "move then trash": `(rule "r" (move "Out") (delete))`,
+ "rename twice": `(rule "r" (rename "r-{name}") (rename "r-{name}"))`,
+ } {
+ t.Run(name, func(t *testing.T) {
+ checkApplyUndo(t, propertyCase{files: map[string]string{"a.pdf": "one"}, rules: "(path \"~/dl\")\n" + rule + "\n"})
+ })
+ }
+}