Skip to content
Myr

clean up testproject files after test executes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by jharshman · committed by Steve Francia · parent 11aa612 · Browse files · 2 files+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+20 added−0 removed

  • other:+20 added−0 removed

2 files+20 added−0 removed

modified:cobra/cmd/add_test.go+13 added
14 unmodified lines
15 Project: &Project{16 AbsolutePath: fmt.Sprintf("%s/testproject", wd),17 Legal: getLicense(),18 Copyright: copyrightLine(),1920 // required to init21 AppName: "testproject",22 PkgName: "github.com/spf13/testproject",23 Viper: true,24 },25 }2627 // init project first28 command.Project.Create()29 defer func() {30 if _, err := os.Stat(command.AbsolutePath); err == nil {31 os.RemoveAll(command.AbsolutePath)32 }33 }()3435 if err := command.Create(); err != nil {36 t.Fatal(err)37 }38
31 unmodified lines
modified:cobra/cmd/init_test.go+7 added
6 unmodified lines
7 "testing"8)910func TestGoldenInitCmd(t *testing.T) {1112 wd, _ := os.Getwd()13 project := &Project{14 AbsolutePath: fmt.Sprintf("%s/testproject", wd),15 PkgName: "github.com/spf13/testproject",
7 unmodified lines
23 if err != nil {24 t.Fatal(err)25 }2627 defer func() {28 if _, err := os.Stat(project.AbsolutePath); err == nil {29 os.RemoveAll(project.AbsolutePath)30 }31 }()3233 expectedFiles := []string{"LICENSE", "main.go", "cmd/root.go"}34 for _, f := range expectedFiles {35 generatedFile := fmt.Sprintf("%s/%s", project.AbsolutePath, f)36 goldenFile := fmt.Sprintf("testdata/%s.golden", filepath.Base(f))
6 unmodified lines