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) {
|
||||
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue