MCPcopy Index your code
hub / github.com/belak/gitdir / TestGetExitStatusFromError

Function TestGetExitStatusFromError

utils_test.go:67–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func 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
99func TestSanitize(t *testing.T) {
100 t.Parallel()

Callers

nothing calls this directly

Calls 1

getExitStatusFromErrorFunction · 0.85

Tested by

no test coverage detected