(t *testing.T)
| 44 | } |
| 45 | |
| 46 | func 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 | |
| 78 | func TestExecStartError(t *testing.T) { |
| 79 | client, err := New( |
nothing calls this directly
no test coverage detected
searching dependent graphs…