MCPcopy
hub / github.com/moby/moby / TestContainerRestart

Function TestContainerRestart

client/container_restart_test.go:40–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestContainerRestart(t *testing.T) {
41 const expectedURL = "/containers/container_id/restart"
42 client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
43 if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
44 return nil, err
45 }
46 s := req.URL.Query().Get("signal")
47 if s != "SIGKILL" {
48 return nil, fmt.Errorf("signal not set in URL query. Expected 'SIGKILL', got '%s'", s)
49 }
50 t := req.URL.Query().Get("t")
51 if t != "100" {
52 return nil, fmt.Errorf("t (timeout) not set in URL query properly. Expected '100', got %s", t)
53 }
54 return mockResponse(http.StatusOK, nil, "")(req)
55 }))
56 assert.NilError(t, err)
57 timeout := 100
58 _, err = client.ContainerRestart(t.Context(), "container_id", ContainerRestartOptions{
59 Signal: "SIGKILL",
60 Timeout: &timeout,
61 })
62 assert.NilError(t, err)
63}

Callers

nothing calls this directly

Calls 8

WithMockClientFunction · 0.85
assertRequestFunction · 0.85
mockResponseFunction · 0.85
ErrorfMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
ContainerRestartMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…