|
@@ -13,6 +13,7 @@ import (
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/docker/docker/api/types/volume"
|
|
"github.com/docker/docker/api/types/volume"
|
|
clientpkg "github.com/docker/docker/client"
|
|
clientpkg "github.com/docker/docker/client"
|
|
|
|
+ "github.com/docker/docker/errdefs"
|
|
"github.com/docker/docker/integration/internal/container"
|
|
"github.com/docker/docker/integration/internal/container"
|
|
"github.com/docker/docker/testutil/request"
|
|
"github.com/docker/docker/testutil/request"
|
|
"github.com/google/go-cmp/cmp/cmpopts"
|
|
"github.com/google/go-cmp/cmp/cmpopts"
|
|
@@ -75,16 +76,31 @@ func TestVolumesRemove(t *testing.T) {
|
|
assert.NilError(t, err)
|
|
assert.NilError(t, err)
|
|
vname := c.Mounts[0].Name
|
|
vname := c.Mounts[0].Name
|
|
|
|
|
|
- err = client.VolumeRemove(ctx, vname, false)
|
|
|
|
- assert.Check(t, is.ErrorContains(err, "volume is in use"))
|
|
|
|
|
|
+ t.Run("volume in use", func(t *testing.T) {
|
|
|
|
+ err = client.VolumeRemove(ctx, vname, false)
|
|
|
|
+ assert.Check(t, is.ErrorType(err, errdefs.IsConflict))
|
|
|
|
+ assert.Check(t, is.ErrorContains(err, "volume is in use"))
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ t.Run("volume not in use", func(t *testing.T) {
|
|
|
|
+ err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{
|
|
|
|
+ Force: true,
|
|
|
|
+ })
|
|
|
|
+ assert.NilError(t, err)
|
|
|
|
|
|
- err = client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{
|
|
|
|
- Force: true,
|
|
|
|
|
|
+ err = client.VolumeRemove(ctx, vname, false)
|
|
|
|
+ assert.NilError(t, err)
|
|
})
|
|
})
|
|
- assert.NilError(t, err)
|
|
|
|
|
|
|
|
- err = client.VolumeRemove(ctx, vname, false)
|
|
|
|
- assert.NilError(t, err)
|
|
|
|
|
|
+ t.Run("non-existing volume", func(t *testing.T) {
|
|
|
|
+ err = client.VolumeRemove(ctx, "no_such_volume", false)
|
|
|
|
+ assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ t.Run("non-existing volume force", func(t *testing.T) {
|
|
|
|
+ err = client.VolumeRemove(ctx, "no_such_volume", true)
|
|
|
|
+ assert.NilError(t, err)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
func TestVolumesInspect(t *testing.T) {
|
|
func TestVolumesInspect(t *testing.T) {
|