mirror of
https://github.com/spf13/cobra
synced 2025-05-06 05:17:21 +00:00
fix: ensure that testproject is removed even after a failure
This commit is contained in:
parent
606aa5792c
commit
891d81cc84
1 changed files with 5 additions and 5 deletions
|
@ -19,17 +19,17 @@ func TestGoldenInitCmd(t *testing.T) {
|
|||
AppName: "testproject",
|
||||
}
|
||||
|
||||
err := project.Create()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if _, err := os.Stat(project.AbsolutePath); err == nil {
|
||||
os.RemoveAll(project.AbsolutePath)
|
||||
}
|
||||
}()
|
||||
|
||||
err := project.Create()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expectedFiles := []string{"LICENSE", "main.go", "cmd/root.go"}
|
||||
for _, f := range expectedFiles {
|
||||
generatedFile := fmt.Sprintf("%s/%s", project.AbsolutePath, f)
|
||||
|
|
Loading…
Add table
Reference in a new issue