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 ccf60c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
14 changes: 1 addition & 13 deletions cobra/cmd/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,13 @@ import (
)

func TestGoldenAddCmd(t *testing.T) {

wd, _ := os.Getwd()
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: 10 additions & 11 deletions cobra/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ import (
"testing"
)

func TestGoldenInitCmd(t *testing.T) {

func getProject() *Project {
wd, _ := os.Getwd()
project := &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) {
project := getProject()
defer os.RemoveAll(project.AbsolutePath)

// init project first
err := project.Create()
if err != nil {
if err := project.Create(); err != nil {
t.Fatal(err)
}

Expand Down

0 comments on commit ccf60c7

Please sign in to comment.