Skip to content

Commit

Permalink
Remove testing for exitOnError
Browse files Browse the repository at this point in the history
  • Loading branch information
tagatac committed Mar 10, 2020
1 parent cc8eff8 commit d1ce519
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,6 @@ import (
"gotest.tools/v3/assert"
)

// Adapted from https://stackoverflow.com/a/33404435/5403337.
func TestExitOnError(t *testing.T) {
if os.Getenv("BAGOUP_TEST_EXIT") == "1" {
var err error
errStr := os.Getenv("BAGOUP_EXIT_ERROR")
if errStr != "" {
err = errors.New(errStr)
}
exitOnError("here's a context string", err)
return
}

tests := []struct {
msg string
wantErr string
wantExitCode int
}{
{
msg: "no error",
},
{
msg: "error",
wantErr: "this is an error",
wantExitCode: 1,
},
}

for _, tt := range tests {
t.Run(tt.msg, func(t *testing.T) {
cmd := exec.Command(os.Args[0], "-test.run=TestExitOnError")
cmd.Env = []string{
"BAGOUP_TEST_EXIT=1",
fmt.Sprintf("BAGOUP_EXIT_ERROR=%s", tt.wantErr),
}
err := cmd.Run()
if tt.wantExitCode == 0 {
assert.NilError(t, err)
return
}
e, ok := err.(*exec.ExitError)
assert.Assert(t, ok)
assert.Equal(t, tt.wantExitCode, e.ExitCode())
})
}
}

func TestGetMacOSVersion(t *testing.T) {
tests := []struct {
msg string
Expand Down

0 comments on commit d1ce519

Please sign in to comment.