diff --git a/cobra/cmd/init_test.go b/cobra/cmd/init_test.go index c4b3f09a21..37e6b89332 100644 --- a/cobra/cmd/init_test.go +++ b/cobra/cmd/init_test.go @@ -11,9 +11,8 @@ import ( ) func getProject() *Project { - wd, _ := os.Getwd() return &Project{ - AbsolutePath: fmt.Sprintf("%s/testproject", wd), + AbsolutePath: fmt.Sprintf("%s/testproject", mustTempDir()), Legal: getLicense(), Copyright: copyrightLine(), AppName: "testproject", @@ -22,6 +21,14 @@ func getProject() *Project { } } +func mustTempDir() string { + dir, err := ioutil.TempDir("", "cobra_cli_test_") + if err != nil { + panic(err) + } + return dir +} + func TestGoldenInitCmd(t *testing.T) { dir, err := ioutil.TempDir("", "cobra-init")