(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestGetExitStatusFromError(t *testing.T) { |
| 68 | t.Parallel() |
| 69 | |
| 70 | // It is way harder than it should be to mock out an ExitError, so we just |
| 71 | // run a command we know will return a valid ExitError. |
| 72 | cmd := exec.Command("sh", "-c", "exit 10") |
| 73 | cmdErr := cmd.Run() |
| 74 | |
| 75 | var tests = []struct { //nolint:gofumpt |
| 76 | Input error |
| 77 | Expected int |
| 78 | }{ |
| 79 | { |
| 80 | nil, |
| 81 | 0, |
| 82 | }, |
| 83 | { |
| 84 | errors.New("non ExitError"), |
| 85 | 1, |
| 86 | }, |
| 87 | { |
| 88 | cmdErr, |
| 89 | 10, |
| 90 | }, |
| 91 | } |
| 92 | |
| 93 | for _, test := range tests { |
| 94 | output := getExitStatusFromError(test.Input) |
| 95 | assert.Equal(t, test.Expected, output) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | func TestSanitize(t *testing.T) { |
| 100 | t.Parallel() |
nothing calls this directly
no test coverage detected