Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test: refactor CLI create tests not to use PTY - #25807

Merged
spikecurtis merged 1 commit into
mainfrom
spike/internal-1400-refactor-create
May 28, 2026
Merged

test: refactor CLI create tests not to use PTY#25807
spikecurtis merged 1 commit into
mainfrom
spike/internal-1400-refactor-create

Conversation

@spikecurtis

@spikecurtis spikecurtis commented May 28, 2026

Copy link
Copy Markdown
Contributor
Part of https://github.com/coder/internal/issues/1400

Refactors CLI tests of the create command as the first batch of tests refactored to take a PTY out of the loop.

One interesting difference I noticed between PTY and a direct pipe to standard in is that on the PTY we write \r to enter some input, but the kernel actually sends \n (or maybe \r\n) to the process, at least on Unix. (On windows we sent \r\n into the PTY). This is reflected in the implementation of the Writer , otherwise mostly inspired by the PTYTest equivalents.

spikecurtis commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Comment thread cli/create_test.go
@@ -1591,9 +1593,6 @@ func TestCreateWithPreset(t *testing.T) {
workspaceName := "my-workspace"
inv, root := clitest.New(t, "create", workspaceName, "--template", template.Name, "-y", "--preset", "invalid-preset")
clitest.SetupConfig(t, member, root)
pty := ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some cases, like this one attach a PTY and then neither read nor write to it.

@spikecurtis
spikecurtis force-pushed the spike/internal-1400-refactor-create branch from ab23d58 to d3cf837 Compare May 28, 2026 19:36
@spikecurtis
spikecurtis force-pushed the spike/internal-1400-expecter branch from 8bb24bb to 9729348 Compare May 28, 2026 19:37
@spikecurtis
spikecurtis marked this pull request as ready for review May 28, 2026 19:44
@spikecurtis
spikecurtis requested a review from sreya May 28, 2026 19:44

@sreya sreya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx for doing this

Comment thread cli/create_test.go
@@ -129,7 +129,8 @@ func TestCreateDynamic(t *testing.T) {
// When enable_region=true, the region parameter becomes required and CLI should prompt.
t.Run("PromptForConditionalParam", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
ctx := testutil.Context(t, time.Hour)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.Hour?

spikecurtis commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • May 28, 9:37 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 28, 9:39 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 28, 9:50 PM UTC: @spikecurtis merged this pull request with Graphite.

@spikecurtis
spikecurtis changed the base branch from spike/internal-1400-expecter to graphite-base/25807 May 28, 2026 21:38
@spikecurtis
spikecurtis changed the base branch from graphite-base/25807 to main May 28, 2026 21:38
@spikecurtis
spikecurtis force-pushed the spike/internal-1400-refactor-create branch from d3cf837 to 23bbd22 Compare May 28, 2026 21:38
@spikecurtis
spikecurtis merged commit ee4126e into main May 28, 2026
29 checks passed
@spikecurtis
spikecurtis deleted the spike/internal-1400-refactor-create branch May 28, 2026 21:50
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants