Files
coder/cli/templateinit_test.go
Mathias Fredriksson c8ed213347 fix: Guard against CLI cmd running after test exit (#1658)
* fix: Guard against CLI cmd running after test exit

* fix: cli: avoid calling t.FailNow in non-test-main goroutine

* fix: cli: server_test: avoid calling t.FailNow outside main goroutine

* fix: cli: clitest_test: avoid calling t.FailNow outside main goroutine

* fix: cli: list_test: avoid calling t.FailNow outside main goroutine

* fix: TestGitSSH use-of-t-after-exit

* fix: TestGitSSH "too many authentication failures"

Due to local SSH keys being given

* chore: clitest: fix TestCli

* chore: Simplify TestTemplateInit

Co-authored-by: Cian Johnston <cian@coder.com>
2022-05-23 20:09:58 +03:00

29 lines
581 B
Go

package cli_test
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/coder/coder/cli/clitest"
"github.com/coder/coder/pty/ptytest"
)
func TestTemplateInit(t *testing.T) {
t.Parallel()
t.Run("Extract", func(t *testing.T) {
t.Parallel()
tempDir := t.TempDir()
cmd, _ := clitest.New(t, "templates", "init", tempDir)
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
err := cmd.Execute()
require.NoError(t, err)
files, err := os.ReadDir(tempDir)
require.NoError(t, err)
require.Greater(t, len(files), 0)
})
}