mirror of
https://github.com/spf13/cobra
synced 2025-05-06 13:27:26 +00:00
cobra/cmd: add getProject test func
This commit is contained in:
parent
c35f8b03e4
commit
ccf60c76a2
2 changed files with 11 additions and 24 deletions
|
@ -7,25 +7,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGoldenAddCmd(t *testing.T) {
|
func TestGoldenAddCmd(t *testing.T) {
|
||||||
|
|
||||||
wd, _ := os.Getwd()
|
|
||||||
command := &Command{
|
command := &Command{
|
||||||
CmdName: "test",
|
CmdName: "test",
|
||||||
CmdParent: parentName,
|
CmdParent: parentName,
|
||||||
Project: &Project{
|
Project: getProject(),
|
||||||
AbsolutePath: fmt.Sprintf("%s/testproject", wd),
|
|
||||||
Legal: getLicense(),
|
|
||||||
Copyright: copyrightLine(),
|
|
||||||
|
|
||||||
// required to init
|
|
||||||
AppName: "testproject",
|
|
||||||
PkgName: "github.com/spf13/testproject",
|
|
||||||
Viper: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(command.AbsolutePath)
|
defer os.RemoveAll(command.AbsolutePath)
|
||||||
|
|
||||||
// init project first
|
|
||||||
command.Project.Create()
|
command.Project.Create()
|
||||||
if err := command.Create(); err != nil {
|
if err := command.Create(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
@ -7,24 +7,23 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGoldenInitCmd(t *testing.T) {
|
func getProject() *Project {
|
||||||
|
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
project := &Project{
|
return &Project{
|
||||||
AbsolutePath: fmt.Sprintf("%s/testproject", wd),
|
AbsolutePath: fmt.Sprintf("%s/testproject", wd),
|
||||||
Legal: getLicense(),
|
Legal: getLicense(),
|
||||||
Copyright: copyrightLine(),
|
Copyright: copyrightLine(),
|
||||||
|
AppName: "testproject",
|
||||||
// required to init
|
PkgName: "github.com/spf13/testproject",
|
||||||
AppName: "testproject",
|
Viper: true,
|
||||||
PkgName: "github.com/spf13/testproject",
|
|
||||||
Viper: true,
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGoldenInitCmd(t *testing.T) {
|
||||||
|
project := getProject()
|
||||||
defer os.RemoveAll(project.AbsolutePath)
|
defer os.RemoveAll(project.AbsolutePath)
|
||||||
|
|
||||||
// init project first
|
if err := project.Create(); err != nil {
|
||||||
err := project.Create()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue