From 754f362da077b06420ab8350dfb62bd2d8d89d75 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 20:13:11 +0200 Subject: plan 8: enum values read from source must all be handled --- internal/engine/enum_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 internal/engine/enum_test.go (limited to 'internal/engine') diff --git a/internal/engine/enum_test.go b/internal/engine/enum_test.go new file mode 100644 index 0000000..416da2a --- /dev/null +++ b/internal/engine/enum_test.go @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package engine + +import ( + "testing" + + "krino/internal/enumtest" + "krino/internal/plan" +) + +// TestEveryKindHasALogAction: every plan.Kind is written to the log under +// its own action word - undo reads the log by that word. plan.Kind is an +// iota block from 0, so the i-th constant is the value i. +func TestEveryKindHasALogAction(t *testing.T) { + kinds, err := enumtest.Names("../plan/step.go", "Kind") + if err != nil { + t.Fatal(err) + } + seen := map[string]bool{} + for i, name := range kinds { + func() { + defer func() { + if r := recover(); r != nil { + t.Errorf("plan.%s has no log action: %v", name, r) + } + }() + a := actionName(plan.Kind(i)) + if a == "" || seen[a] { + t.Errorf("plan.%s logs as %q", name, a) + } + seen[a] = true + }() + } +} -- cgit v1.3