From 9e65644f473d75ceb7e3ef67302189eeaba0f922 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 22:39:27 +0200 Subject: plan 10: missing and weak tests (per-step logging, trash path, fuzz oracle, w after error) --- cmd/krino/review_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'cmd/krino/review_test.go') 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) + } + } +} -- cgit v1.3