From d2ea5adfe401205d39050abe117cd1cb6811764b Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:53:30 +0100 Subject: [PATCH] fix: flaky prompt termination on reader close test Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- cli/command/utils_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cli/command/utils_test.go b/cli/command/utils_test.go index 869b33b644..2a469a65a7 100644 --- a/cli/command/utils_test.go +++ b/cli/command/utils_test.go @@ -197,13 +197,11 @@ func TestPromptForConfirmation(t *testing.T) { promptReader, promptWriter = io.Pipe() wroteHook := make(chan struct{}, 1) - defer close(wroteHook) promptOut := test.NewWriterWithHook(bufioWriter, func(p []byte) { wroteHook <- struct{}{} }) result := make(chan promptResult, 1) - defer close(result) go func() { r, err := command.PromptForConfirmation(ctx, promptReader, promptOut, "") result <- promptResult{r, err} @@ -216,7 +214,7 @@ func TestPromptForConfirmation(t *testing.T) { assert.NilError(t, bufioWriter.Flush()) assert.Equal(t, strings.TrimSpace(buf.String()), "Are you sure you want to proceed? [y/N]") - resultCtx, resultCancel := context.WithTimeout(ctx, 100*time.Millisecond) + resultCtx, resultCancel := context.WithTimeout(ctx, 500*time.Millisecond) defer resultCancel() tc.f(t, resultCtx, result)