MCPcopy
hub / github.com/moby/moby / TestExecCreate

Function TestExecCreate

client/container_exec_test.go:46–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestExecCreate(t *testing.T) {
47 const expectedURL = "/containers/container_id/exec"
48 client, err := New(
49 WithMockClient(func(req *http.Request) (*http.Response, error) {
50 if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
51 return nil, err
52 }
53 // FIXME validate the content is the given ExecConfig ?
54 if err := req.ParseForm(); err != nil {
55 return nil, err
56 }
57 execConfig := &container.ExecCreateRequest{}
58 if err := json.NewDecoder(req.Body).Decode(execConfig); err != nil {
59 return nil, err
60 }
61 if execConfig.User != "user" {
62 return nil, fmt.Errorf("expected an execConfig with User == 'user', got %v", execConfig)
63 }
64 return mockJSONResponse(http.StatusOK, nil, container.ExecCreateResponse{
65 ID: "exec_id",
66 })(req)
67 }),
68 )
69 assert.NilError(t, err)
70
71 res, err := client.ExecCreate(t.Context(), "container_id", ExecCreateOptions{
72 User: "user",
73 })
74 assert.NilError(t, err)
75 assert.Check(t, is.Equal(res.ID, "exec_id"))
76}
77
78func TestExecStartError(t *testing.T) {
79 client, err := New(

Callers

nothing calls this directly

Calls 10

WithMockClientFunction · 0.85
assertRequestFunction · 0.85
mockJSONResponseFunction · 0.85
ErrorfMethod · 0.80
CheckMethod · 0.80
EqualMethod · 0.80
NewFunction · 0.70
DecodeMethod · 0.65
ExecCreateMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…