aboutsummaryrefslogtreecommitdiff
path: root/internal/journal/read_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/journal/read_test.go')
-rw-r--r--internal/journal/read_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/journal/read_test.go b/internal/journal/read_test.go
index efb5a15..4f1c902 100644
--- a/internal/journal/read_test.go
+++ b/internal/journal/read_test.go
@@ -779,3 +779,34 @@ func TestRunsMarksAPartlyUndoneRun(t *testing.T) {
t.Errorf("after both reversals: %+v, want undone in full", a)
}
}
+
+// TestRunsIgnoresAPermanentlyDeletedFilesSteps: a file whose chain ended in
+// a permanent delete can never be undone, so its earlier steps do not keep
+// the run partly undone forever (plan 11 review L8).
+func TestRunsIgnoresAPermanentlyDeletedFilesSteps(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "krino.log")
+ w, _ := Open(path)
+ t0 := time.Date(2026, 9, 11, 9, 0, 0, 0, time.UTC)
+ for _, e := range []Entry{
+ {Time: t0, Run: "A", Action: "run-start", Status: "ok"},
+ {Time: t0, Run: "A", Dir: "dl", File: "x.pdf", Step: 1, Action: "move", Status: "ok", Src: "/a/x.pdf", Dst: "/b/x.pdf"},
+ {Time: t0, Run: "A", Dir: "dl", File: "y.pdf", Step: 1, Action: "rename", Status: "ok", Src: "/a/y.pdf", Dst: "/a/z.pdf"},
+ {Time: t0, Run: "A", Dir: "dl", File: "y.pdf", Step: 2, Action: "delete", Status: "ok", Src: "/a/z.pdf"},
+ {Time: t0, Run: "A", Action: "run-end", Status: "ok"},
+ {Time: t0.Add(time.Hour), Run: "B", Action: "run-start", Status: "ok", Detail: "undo of A"},
+ {Time: t0.Add(time.Hour), Run: "B", Dir: "dl", File: "x.pdf", Step: 1, Action: "undo-move", Status: "ok", Src: "/b/x.pdf", Dst: "/a/x.pdf"},
+ {Time: t0.Add(time.Hour), Run: "B", Action: "run-end", Status: "ok"},
+ } {
+ w.Append(e)
+ }
+ w.Close()
+ runs, err := Runs(path, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, r := range runs {
+ if r.ID == "A" && (!r.Undone || r.PartlyUndone) {
+ t.Errorf("run A = %+v; want undone in full: y.pdf could never be reversed", r)
+ }
+ }
+}