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