MCPcopy
hub / github.com/moby/moby / TestFailedExecExitCode

Function TestFailedExecExitCode

integration/container/exec_linux_test.go:37–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestFailedExecExitCode(t *testing.T) {
38 testCases := []struct {
39 doc string
40 command []string
41 expectedExitCode int
42 }{
43 {
44 doc: "executable not found",
45 command: []string{"nonexistent"},
46 expectedExitCode: 127,
47 },
48 {
49 doc: "executable cannot be invoked",
50 command: []string{"/etc"},
51 expectedExitCode: 126,
52 },
53 }
54
55 for _, tc := range testCases {
56 t.Run(tc.doc, func(t *testing.T) {
57 ctx := setupTest(t)
58 apiClient := testEnv.APIClient()
59
60 cID := container.Run(ctx, t, apiClient)
61
62 result, err := container.Exec(ctx, apiClient, cID, tc.command)
63 assert.NilError(t, err)
64
65 assert.Equal(t, result.ExitCode, tc.expectedExitCode)
66 })
67 }
68}

Callers

nothing calls this directly

Calls 6

RunFunction · 0.92
ExecFunction · 0.92
APIClientMethod · 0.80
EqualMethod · 0.80
setupTestFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…