Skip to content

fix: Guard against CLI cmd running after test exit #1658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 23, 2022
Prev Previous commit
Next Next commit
fix: cli: avoid calling t.FailNow in non-test-main goroutine
  • Loading branch information
johnstcn committed May 23, 2022
commit 53417bb09aecdf9fcd682eb2d85051465ed0372f
8 changes: 3 additions & 5 deletions cli/userlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ func TestUserList(t *testing.T) {
coderdtest.CreateFirstUser(t, client)
cmd, root := clitest.New(t, "users", "list")
clitest.SetupConfig(t, client, root)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
errC := make(chan error)
go func() {
defer close(doneChan)
err := cmd.Execute()
require.NoError(t, err)
errC <- cmd.Execute()
}()
require.NoError(t, <-errC)
pty.ExpectMatch("coder.com")
<-doneChan
}