-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate some copy tests to integration
Signed-off-by: Daniel Nephin <[email protected]>
- Loading branch information
Showing
4 changed files
with
66 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package container // import "github.com/docker/docker/integration/container" | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/client" | ||
"github.com/docker/docker/integration/internal/container" | ||
"github.com/docker/docker/internal/testutil" | ||
"github.com/gotestyourself/gotestyourself/skip" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCopyFromContainerPathDoesNotExist(t *testing.T) { | ||
defer setupTest(t)() | ||
|
||
ctx := context.Background() | ||
apiclient := testEnv.APIClient() | ||
cid := container.Create(t, ctx, apiclient) | ||
|
||
_, _, err := apiclient.CopyFromContainer(ctx, cid, "/dne") | ||
require.True(t, client.IsErrNotFound(err)) | ||
expected := fmt.Sprintf("No such container:path: %s:%s", cid, "/dne") | ||
testutil.ErrorContains(t, err, expected) | ||
} | ||
|
||
func TestCopyFromContainerPathIsNotDir(t *testing.T) { | ||
defer setupTest(t)() | ||
skip.If(t, testEnv.OSType == "windows") | ||
|
||
ctx := context.Background() | ||
apiclient := testEnv.APIClient() | ||
cid := container.Create(t, ctx, apiclient) | ||
|
||
_, _, err := apiclient.CopyFromContainer(ctx, cid, "/etc/passwd/") | ||
require.Contains(t, err.Error(), "not a directory") | ||
} | ||
|
||
func TestCopyToContainerPathDoesNotExist(t *testing.T) { | ||
defer setupTest(t)() | ||
skip.If(t, testEnv.OSType == "windows") | ||
|
||
ctx := context.Background() | ||
apiclient := testEnv.APIClient() | ||
cid := container.Create(t, ctx, apiclient) | ||
|
||
err := apiclient.CopyToContainer(ctx, cid, "/dne", nil, types.CopyToContainerOptions{}) | ||
require.True(t, client.IsErrNotFound(err)) | ||
expected := fmt.Sprintf("No such container:path: %s:%s", cid, "/dne") | ||
testutil.ErrorContains(t, err, expected) | ||
} | ||
|
||
func TestCopyToContainerPathIsNotDir(t *testing.T) { | ||
defer setupTest(t)() | ||
skip.If(t, testEnv.OSType == "windows") | ||
|
||
ctx := context.Background() | ||
apiclient := testEnv.APIClient() | ||
cid := container.Create(t, ctx, apiclient) | ||
|
||
err := apiclient.CopyToContainer(ctx, cid, "/etc/passwd/", nil, types.CopyToContainerOptions{}) | ||
require.Contains(t, err.Error(), "not a directory") | ||
} |