diff options
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) + } + } +} |
