aboutsummaryrefslogtreecommitdiff
path: root/internal/journal/read_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 00:33:47 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 00:33:47 +0200
commit2a7452c3fd83000f239755825f38246f8537b6cc (patch)
tree1413ef2f8776927efb7f37b6ba492330920ef3f3 /internal/journal/read_test.go
parenteb31377e43fb26a6726b741978db83453fcd7bdd (diff)
downloadkrino-2a7452c3fd83000f239755825f38246f8537b6cc.tar.gz
krino-2a7452c3fd83000f239755825f38246f8537b6cc.zip
a permanently deleted file's steps do not keep a run partly undone
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)
+ }
+ }
+}