diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 21:43:23 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 21:43:23 +0200 |
| commit | c497d173b24b1b8247fac9e996e5c0fe690c1769 (patch) | |
| tree | 2318ff1cf393e3a6c2a7d54c89e205ac6a9a5c73 /internal/plan | |
| parent | 360591d6e18d8676a2f86185ed42f46852387f85 (diff) | |
| download | krino-c497d173b24b1b8247fac9e996e5c0fe690c1769.tar.gz krino-c497d173b24b1b8247fac9e996e5c0fe690c1769.zip | |
plan 9: undo review matches review, --min-age validated, future mtimes, rule names, conflict enum, dependency gate, absolute tool paths
Diffstat (limited to 'internal/plan')
| -rw-r--r-- | internal/plan/conflict.go | 5 | ||||
| -rw-r--r-- | internal/plan/enum_test.go | 27 |
2 files changed, 31 insertions, 1 deletions
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{}) +} |
