aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/enum_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/engine/enum_test.go')
-rw-r--r--internal/engine/enum_test.go35
1 files changed, 35 insertions, 0 deletions
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
+ }()
+ }
+}