12 "golang.org/x/net/context"
15 func TestContainerStopError(t *testing.T) {
17 client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
19 timeout := 0 * time.Second
20 err := client.ContainerStop(context.Background(), "nothing", &timeout)
21 if err == nil || err.Error() != "Error response from daemon: Server error" {
22 t.Fatalf("expected a Server Error, got %v", err)
26 func TestContainerStop(t *testing.T) {
27 expectedURL := "/containers/container_id/stop"
29 client: newMockClient(func(req *http.Request) (*http.Response, error) {
30 if !strings.HasPrefix(req.URL.Path, expectedURL) {
31 return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
33 t := req.URL.Query().Get("t")
35 return nil, fmt.Errorf("t (timeout) not set in URL query properly. Expected '100', got %s", t)
37 return &http.Response{
38 StatusCode: http.StatusOK,
39 Body: ioutil.NopCloser(bytes.NewReader([]byte(""))),
43 timeout := 100 * time.Second
44 err := client.ContainerStop(context.Background(), "container_id", &timeout)