style: simply defer os.RemoveAll

This commit is contained in:
umarcor 2019-09-08 15:40:54 +02:00
parent 7a0cf95b2a
commit c35f8b03e4
2 changed files with 8 additions and 15 deletions

View file

@ -23,15 +23,10 @@ func TestGoldenAddCmd(t *testing.T) {
Viper: true,
},
}
defer os.RemoveAll(command.AbsolutePath)
// init project first
command.Project.Create()
defer func() {
if _, err := os.Stat(command.AbsolutePath); err == nil {
os.RemoveAll(command.AbsolutePath)
}
}()
if err := command.Create(); err != nil {
t.Fatal(err)
}

View file

@ -12,19 +12,17 @@ func TestGoldenInitCmd(t *testing.T) {
wd, _ := os.Getwd()
project := &Project{
AbsolutePath: fmt.Sprintf("%s/testproject", wd),
PkgName: "github.com/spf13/testproject",
Legal: getLicense(),
Copyright: copyrightLine(),
Viper: true,
AppName: "testproject",
// required to init
AppName: "testproject",
PkgName: "github.com/spf13/testproject",
Viper: true,
}
defer os.RemoveAll(project.AbsolutePath)
defer func() {
if _, err := os.Stat(project.AbsolutePath); err == nil {
os.RemoveAll(project.AbsolutePath)
}
}()
// init project first
err := project.Create()
if err != nil {
t.Fatal(err)