diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 22:39:27 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 22:39:27 +0200 |
| commit | 9e65644f473d75ceb7e3ef67302189eeaba0f922 (patch) | |
| tree | 6cde9486fb55e035f5e9041f5ba2cd579c9c8ff2 /cmd/krino/review_test.go | |
| parent | 8227de6a887c8600746b06d1287cb2b00de77e28 (diff) | |
| download | krino-9e65644f473d75ceb7e3ef67302189eeaba0f922.tar.gz krino-9e65644f473d75ceb7e3ef67302189eeaba0f922.zip | |
plan 10: missing and weak tests (per-step logging, trash path, fuzz oracle, w after error)
Diffstat (limited to 'cmd/krino/review_test.go')
| -rw-r--r-- | cmd/krino/review_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/krino/review_test.go b/cmd/krino/review_test.go index a1fbba7..b138451 100644 --- a/cmd/krino/review_test.go +++ b/cmd/krino/review_test.go @@ -3,6 +3,9 @@ package main import ( + "context" + "errors" + "fmt" "io" "strings" "testing" @@ -295,3 +298,31 @@ func TestNotReviewedOutcome(t *testing.T) { t.Errorf("got %q", got) } } + +// TestStopAfterApply: [w] stops krino after its directory whether or not the +// apply succeeded (review cli F3) - a log that cannot be written must not +// lead on to planning and prompting the next directory - and an interrupt +// always stops it. +func TestStopAfterApply(t *testing.T) { + logErr := errors.New("write krino.log: no space left on device") + cases := []struct { + action rune + err error + want bool + }{ + {'a', nil, false}, + {'c', nil, false}, + {'w', nil, true}, + {'a', logErr, false}, + {'c', logErr, false}, + {'w', logErr, true}, + {'a', context.Canceled, true}, + {'c', fmt.Errorf("apply: %w", context.Canceled), true}, + {'a', context.DeadlineExceeded, true}, + } + for _, c := range cases { + if got := stopAfterApply(c.action, c.err); got != c.want { + t.Errorf("stopAfterApply(%q, %v) = %v, want %v", c.action, c.err, got, c.want) + } + } +} |
