From c497d173b24b1b8247fac9e996e5c0fe690c1769 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 21:43:23 +0200 Subject: plan 9: undo review matches review, --min-age validated, future mtimes, rule names, conflict enum, dependency gate, absolute tool paths --- internal/plan/conflict.go | 5 ++++- internal/plan/enum_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'internal/plan') diff --git a/internal/plan/conflict.go b/internal/plan/conflict.go index c4c6b64..c660a8b 100644 --- a/internal/plan/conflict.go +++ b/internal/plan/conflict.go @@ -120,10 +120,13 @@ func resolveConflict(kind Kind, policy config.Conflict, src, dst string, d Disk, // displaces nothing. resolved, skip := suffixed(dst, d, c) return resolved, skip, "" - default: // config.ConflictSuffix + case config.ConflictSuffix: resolved, skip := suffixed(dst, d, c) return resolved, skip, "" } + // Every policy has its own branch (review cli F13): a new one must not + // quietly plan as another. + panic(fmt.Sprintf("plan: unknown config.Conflict %d", int(policy))) } // maxSuffixAttempts bounds suffixed(): it is unbounded by design and diff --git a/internal/plan/enum_test.go b/internal/plan/enum_test.go index 6458f5f..5e4f645 100644 --- a/internal/plan/enum_test.go +++ b/internal/plan/enum_test.go @@ -45,3 +45,30 @@ func TestEveryKindIsNamed(t *testing.T) { }() } } + +// TestEveryConflictPolicyIsPlanned: every config.Conflict value is resolved +// by its own branch; an unknown value panics instead of quietly planning as +// suffix (review cli F13). Conflict is an iota block from 0. +func TestEveryConflictPolicyIsPlanned(t *testing.T) { + policies, err := enumtest.Names("../config/settings.go", "Conflict") + if err != nil { + t.Fatal(err) + } + d := fakeDisk{exists: map[string]bool{"/r/b.pdf": true}} + for i, name := range policies { + func() { + defer func() { + if r := recover(); r != nil { + t.Errorf("config.%s is not planned: %v", name, r) + } + }() + resolveConflict(Move, config.Conflict(i), "/r/a.pdf", "/r/b.pdf", d, claimed{}) + }() + } + defer func() { + if recover() == nil { + t.Error("an unknown conflict policy did not panic") + } + }() + resolveConflict(Move, config.Conflict(len(policies)), "/r/a.pdf", "/r/b.pdf", d, claimed{}) +} -- cgit v1.3