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
chore: Simplify TestTemplateInit
  • Loading branch information
mafredri committed May 23, 2022
commit ed95609a2575166d279c51622deee2e0e70a4aa3
9 changes: 2 additions & 7 deletions cli/templateinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ func TestTemplateInit(t *testing.T) {
t.Parallel()
tempDir := t.TempDir()
cmd, _ := clitest.New(t, "templates", "init", tempDir)
doneChan := make(chan struct{})
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
go func() {
defer close(doneChan)
err := cmd.Execute()
require.NoError(t, err)
}()
<-doneChan
err := cmd.Execute()
require.NoError(t, err)
files, err := os.ReadDir(tempDir)
require.NoError(t, err)
require.Greater(t, len(files), 0)
Expand Down