gopkg.in/moby/moby.v1@v1.13.1/client/container_unpause_test.go (about) 1 package client 2 3 import ( 4 "bytes" 5 "fmt" 6 "io/ioutil" 7 "net/http" 8 "strings" 9 "testing" 10 11 "golang.org/x/net/context" 12 ) 13 14 func TestContainerUnpauseError(t *testing.T) { 15 client := &Client{ 16 client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), 17 } 18 err := client.ContainerUnpause(context.Background(), "nothing") 19 if err == nil || err.Error() != "Error response from daemon: Server error" { 20 t.Fatalf("expected a Server Error, got %v", err) 21 } 22 } 23 24 func TestContainerUnpause(t *testing.T) { 25 expectedURL := "/containers/container_id/unpause" 26 client := &Client{ 27 client: newMockClient(func(req *http.Request) (*http.Response, error) { 28 if !strings.HasPrefix(req.URL.Path, expectedURL) { 29 return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) 30 } 31 return &http.Response{ 32 StatusCode: http.StatusOK, 33 Body: ioutil.NopCloser(bytes.NewReader([]byte(""))), 34 }, nil 35 }), 36 } 37 err := client.ContainerUnpause(context.Background(), "container_id") 38 if err != nil { 39 t.Fatal(err) 40 } 41 }