aboutsummaryrefslogtreecommitdiff
path: root/internal/plan/chain_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/plan/chain_test.go')
-rw-r--r--internal/plan/chain_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/plan/chain_test.go b/internal/plan/chain_test.go
index b6e3dfe..28c208f 100644
--- a/internal/plan/chain_test.go
+++ b/internal/plan/chain_test.go
@@ -141,3 +141,31 @@ func TestBuildKeepsSteplessChains(t *testing.T) {
}
}
}
+
+// TestBuildNoDeleteSkipsDeletesAndContinues is spec §5.5 rule 2 and §7.1:
+// with Input.NoDelete set, every delete step is skipped with that reason,
+// and the chain carries on from the file's current path instead of ending.
+func TestBuildNoDeleteSkipsDeletesAndContinues(t *testing.T) {
+ in := []Input{{
+ File: file("/r", "b.pdf"),
+ NoDelete: "a duplicate is never deleted",
+ Rules: []RuleMatch{
+ {Name: "old", Actions: []config.Action{act(config.DeletePermanent, "")}},
+ {Name: "dupes", Actions: []config.Action{act(config.Move, "Dupes")}},
+ {Name: "cleanup", Actions: []config.Action{act(config.Delete, "")}},
+ },
+ }}
+ steps := Build("/r", in, time.Now(), NoDisk{}, NewClaims())[0].Steps
+ if len(steps) != 3 {
+ t.Fatalf("steps = %+v", steps)
+ }
+ if steps[0].Kind != DeletePermanent || steps[0].Skip != "a duplicate is never deleted" {
+ t.Errorf("step 0 = %+v, want a skipped permanent delete", steps[0])
+ }
+ if steps[1].Kind != Move || steps[1].Skip != "" || steps[1].Dst != "/r/Dupes/b.pdf" {
+ t.Errorf("step 1 = %+v, want the move to run", steps[1])
+ }
+ if steps[2].Kind != Trash || steps[2].Skip != "a duplicate is never deleted" || steps[2].Src != "/r/Dupes/b.pdf" {
+ t.Errorf("step 2 = %+v, want a skipped trash from the moved path", steps[2])
+ }
+}