diff --git a/cobra/cmd/add_test.go b/cobra/cmd/add_test.go index b3d01016b3..513b395185 100644 --- a/cobra/cmd/add_test.go +++ b/cobra/cmd/add_test.go @@ -12,20 +12,10 @@ func TestGoldenAddCmd(t *testing.T) { command := &Command{ CmdName: "test", CmdParent: parentName, - Project: &Project{ - AbsolutePath: fmt.Sprintf("%s/testproject", wd), - Legal: getLicense(), - Copyright: copyrightLine(), - - // required to init - AppName: "testproject", - PkgName: "github.com/spf13/testproject", - Viper: true, - }, + Project: getProject(), } defer os.RemoveAll(command.AbsolutePath) - // init project first command.Project.Create() if err := command.Create(); err != nil { t.Fatal(err) diff --git a/cobra/cmd/init_test.go b/cobra/cmd/init_test.go index fd8f87f036..d01578fc68 100644 --- a/cobra/cmd/init_test.go +++ b/cobra/cmd/init_test.go @@ -7,22 +7,23 @@ import ( "testing" ) -func TestGoldenInitCmd(t *testing.T) { - - wd, _ := os.Getwd() - project := &Project{ +func getProject() *Project { + return &Project{ AbsolutePath: fmt.Sprintf("%s/testproject", wd), Legal: getLicense(), Copyright: copyrightLine(), - - // required to init - AppName: "testproject", - PkgName: "github.com/spf13/testproject", - Viper: true, + AppName: "testproject", + PkgName: "github.com/spf13/testproject", + Viper: true, } +} + +func TestGoldenInitCmd(t *testing.T) { + + wd, _ := os.Getwd() + project := getProject() defer os.RemoveAll(project.AbsolutePath) - // init project first err := project.Create() if err != nil { t.Fatal(err)