mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Wrap response errors for container copy methods.
This allows IsErrNotFound and IsErrNotImplemented to work as intended. Signed-off-by: Emil Davtyan <emil2k@gmail.com>
This commit is contained in:
@@ -25,6 +25,16 @@ func TestContainerStatPathError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerStatPathNotFoundError(t *testing.T) {
|
||||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
|
||||
}
|
||||
_, err := client.ContainerStatPath(context.Background(), "container_id", "path")
|
||||
if !IsErrNotFound(err) {
|
||||
t.Fatalf("expected a not found error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerStatPathNoHeaderError(t *testing.T) {
|
||||
client := &Client{
|
||||
client: newMockClient(func(req *http.Request) (*http.Response, error) {
|
||||
@@ -95,6 +105,16 @@ func TestCopyToContainerError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCopyToContainerNotFoundError(t *testing.T) {
|
||||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
|
||||
}
|
||||
err := client.CopyToContainer(context.Background(), "container_id", "path/to/file", bytes.NewReader([]byte("")), types.CopyToContainerOptions{})
|
||||
if !IsErrNotFound(err) {
|
||||
t.Fatalf("expected a not found error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCopyToContainerNotStatusOKError(t *testing.T) {
|
||||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusNoContent, "No content")),
|
||||
@@ -161,6 +181,16 @@ func TestCopyFromContainerError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCopyFromContainerNotFoundError(t *testing.T) {
|
||||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
|
||||
}
|
||||
_, _, err := client.CopyFromContainer(context.Background(), "container_id", "path/to/file")
|
||||
if !IsErrNotFound(err) {
|
||||
t.Fatalf("expected a not found error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCopyFromContainerNotStatusOKError(t *testing.T) {
|
||||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusNoContent, "No content")),
|
||||
|
||||
Reference in New Issue
Block a user