1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
package main
import (
"strings"
"testing"
)
func TestMain(t *testing.T) {
testCases := []struct {
args []string
exitCode int
}{
{
args: []string{"-help"},
exitCode: 2,
},
{
args: []string{"extract"},
exitCode: 0,
},
{
args: []string{"merge"},
exitCode: 1,
},
}
for _, testCase := range testCases {
t.Run(strings.Join(testCase.args, " "), func(t *testing.T) {
if code := testableMain(testCase.args); code != testCase.exitCode {
t.Fatalf("expected exit code %d; got %d", testCase.exitCode, code)
}
})
}
}
|