Skip to content

Commit

Permalink
cobra/cmd: add getProject test func
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Sep 17, 2019
1 parent c35f8b0 commit 141230d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
12 changes: 1 addition & 11 deletions cobra/cmd/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 11 additions & 10 deletions cobra/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 141230d

Please sign in to comment.