diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 20:13:11 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 20:13:11 +0200 |
| commit | 754f362da077b06420ab8350dfb62bd2d8d89d75 (patch) | |
| tree | 513d643876f12ad423f9338209ed9c0b607e7b39 /internal/plan/enum_test.go | |
| parent | 792e6e5416a51fb05f7171aa7ef4f9a284a8cf68 (diff) | |
| download | krino-754f362da077b06420ab8350dfb62bd2d8d89d75.tar.gz krino-754f362da077b06420ab8350dfb62bd2d8d89d75.zip | |
plan 8: enum values read from source must all be handled
Diffstat (limited to 'internal/plan/enum_test.go')
| -rw-r--r-- | internal/plan/enum_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/internal/plan/enum_test.go b/internal/plan/enum_test.go new file mode 100644 index 0000000..6458f5f --- /dev/null +++ b/internal/plan/enum_test.go @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package plan + +import ( + "strings" + "testing" + + "krino/internal/config" + "krino/internal/enumtest" +) + +// TestEveryKindIsNamed: every Kind has its own display name and a JSON +// action name, and every config.ActionKind maps onto a Kind. Kind and +// ActionKind are iota blocks from 0, so the i-th constant is the value i. +func TestEveryKindIsNamed(t *testing.T) { + kinds, err := enumtest.Names("step.go", "Kind") + if err != nil { + t.Fatal(err) + } + seen := map[string]bool{} + for i, name := range kinds { + k := Kind(i) + if s := k.String(); strings.HasPrefix(s, "Kind(") || seen[s] { + t.Errorf("%s: String() = %q", name, s) + } else { + seen[s] = true + } + if actionNames[k] == "" { + t.Errorf("%s has no JSON action name", name) + } + } + actions, err := enumtest.Names("../config/dir.go", "ActionKind") + if err != nil { + t.Fatal(err) + } + for i, name := range actions { + func() { + defer func() { + if r := recover(); r != nil { + t.Errorf("config.%s has no plan.Kind: %v", name, r) + } + }() + stepKind(config.ActionKind(i)) + }() + } +} |
