Skip to content

Commit 1b7b6a6

Browse files
committed
fix: wait for prompt on rich param CLI test
1 parent f0a4de5 commit 1b7b6a6

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

cli/update_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
418418
err := inv.Run()
419419
require.NoError(t, err)
420420

421+
ctx := testutil.Context(t, testutil.WaitLong)
421422
inv, root = clitest.New(t, "update", "my-workspace", "--always-prompt")
423+
inv = inv.WithContext(ctx)
422424
clitest.SetupConfig(t, member, root)
423425
doneChan := make(chan struct{})
424426
pty := ptytest.New(t).Attach(inv)
@@ -428,18 +430,16 @@ func TestUpdateValidateRichParameters(t *testing.T) {
428430
assert.NoError(t, err)
429431
}()
430432

431-
matches := []string{
432-
boolParameterName, "cat",
433-
"boolean value can be either", "",
434-
"Enter a value", "false",
435-
}
436-
for i := 0; i < len(matches); i += 2 {
437-
match := matches[i]
438-
value := matches[i+1]
439-
pty.ExpectMatch(match)
440-
pty.WriteLine(value)
441-
}
442-
<-doneChan
433+
pty.ExpectMatch(boolParameterName)
434+
pty.ExpectMatch("> Enter a value (default: \"\"): ")
435+
pty.WriteLine("cat")
436+
pty.ExpectMatch("boolean value can be either \"true\" or \"false\"")
437+
pty.ExpectMatch("> Enter a value (default: \"\"): ")
438+
pty.WriteLine("")
439+
pty.ExpectMatch("boolean value can be either \"true\" or \"false\"")
440+
pty.ExpectMatch("> Enter a value (default: \"\"): ")
441+
pty.WriteLine("false")
442+
_ = testutil.RequireRecvCtx(ctx, t, doneChan)
443443
})
444444

445445
t.Run("RequiredParameterAdded", func(t *testing.T) {

pty/ptytest/ptytest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (e *outExpecter) expectMatcherFunc(ctx context.Context, str string, fn func
198198
e.fatalf("read error", "%v (wanted %q; got %q)", err, str, buffer.String())
199199
return ""
200200
}
201-
e.logf("matched %q = %q", str, stripansi.Strip(buffer.String()))
201+
e.logf("matched %q = %q", str, buffer.String())
202202
return buffer.String()
203203
}
204204

0 commit comments

Comments
 (0)