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