cli/command/volume: remove uses of pkg/errors in tests
While there may be reasons to keep pkg/errors in production code, we don't need them for these tests. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
bdd70c1c61
commit
10aca7dd50
@ -1,6 +1,8 @@
|
|||||||
package volume
|
package volume
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
@ -9,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
)
|
)
|
||||||
@ -34,7 +35,7 @@ func TestVolumeCreateErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumeCreateFunc: func(createBody volume.CreateOptions) (volume.Volume, error) {
|
volumeCreateFunc: func(createBody volume.CreateOptions) (volume.Volume, error) {
|
||||||
return volume.Volume{}, errors.Errorf("error creating volume")
|
return volume.Volume{}, errors.New("error creating volume")
|
||||||
},
|
},
|
||||||
expectedError: "error creating volume",
|
expectedError: "error creating volume",
|
||||||
},
|
},
|
||||||
@ -60,7 +61,7 @@ func TestVolumeCreateWithName(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
|
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
|
||||||
if body.Name != name {
|
if body.Name != name {
|
||||||
return volume.Volume{}, errors.Errorf("expected name %q, got %q", name, body.Name)
|
return volume.Volume{}, fmt.Errorf("expected name %q, got %q", name, body.Name)
|
||||||
}
|
}
|
||||||
return volume.Volume{
|
return volume.Volume{
|
||||||
Name: body.Name,
|
Name: body.Name,
|
||||||
@ -99,16 +100,16 @@ func TestVolumeCreateWithFlags(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
|
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
|
||||||
if body.Name != "" {
|
if body.Name != "" {
|
||||||
return volume.Volume{}, errors.Errorf("expected empty name, got %q", body.Name)
|
return volume.Volume{}, fmt.Errorf("expected empty name, got %q", body.Name)
|
||||||
}
|
}
|
||||||
if body.Driver != expectedDriver {
|
if body.Driver != expectedDriver {
|
||||||
return volume.Volume{}, errors.Errorf("expected driver %q, got %q", expectedDriver, body.Driver)
|
return volume.Volume{}, fmt.Errorf("expected driver %q, got %q", expectedDriver, body.Driver)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(body.DriverOpts, expectedOpts) {
|
if !reflect.DeepEqual(body.DriverOpts, expectedOpts) {
|
||||||
return volume.Volume{}, errors.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts)
|
return volume.Volume{}, fmt.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(body.Labels, expectedLabels) {
|
if !reflect.DeepEqual(body.Labels, expectedLabels) {
|
||||||
return volume.Volume{}, errors.Errorf("expected labels %v, got %v", expectedLabels, body.Labels)
|
return volume.Volume{}, fmt.Errorf("expected labels %v, got %v", expectedLabels, body.Labels)
|
||||||
}
|
}
|
||||||
return volume.Volume{
|
return volume.Volume{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package volume
|
package volume
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
@ -9,7 +10,6 @@ import (
|
|||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
)
|
)
|
||||||
@ -27,7 +27,7 @@ func TestVolumeInspectErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
|
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
|
||||||
return volume.Volume{}, errors.Errorf("error while inspecting the volume")
|
return volume.Volume{}, errors.New("error while inspecting the volume")
|
||||||
},
|
},
|
||||||
expectedError: "error while inspecting the volume",
|
expectedError: "error while inspecting the volume",
|
||||||
},
|
},
|
||||||
@ -46,7 +46,7 @@ func TestVolumeInspectErrors(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return volume.Volume{}, errors.Errorf("error while inspecting the volume")
|
return volume.Volume{}, errors.New("error while inspecting the volume")
|
||||||
},
|
},
|
||||||
expectedError: "error while inspecting the volume",
|
expectedError: "error while inspecting the volume",
|
||||||
},
|
},
|
||||||
@ -78,7 +78,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
|
|||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
|
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
|
||||||
if volumeID != "foo" {
|
if volumeID != "foo" {
|
||||||
return volume.Volume{}, errors.Errorf("Invalid volumeID, expected %s, got %s", "foo", volumeID)
|
return volume.Volume{}, fmt.Errorf("invalid volumeID, expected %s, got %s", "foo", volumeID)
|
||||||
}
|
}
|
||||||
return *builders.Volume(), nil
|
return *builders.Volume(), nil
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package volume
|
package volume
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -9,7 +10,6 @@ import (
|
|||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"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"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
)
|
)
|
||||||
@ -27,7 +27,7 @@ func TestVolumeListErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||||
return volume.ListResponse{}, errors.Errorf("error listing volumes")
|
return volume.ListResponse{}, errors.New("error listing volumes")
|
||||||
},
|
},
|
||||||
expectedError: "error listing volumes",
|
expectedError: "error listing volumes",
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,7 @@ package volume
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -12,7 +13,6 @@ import (
|
|||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"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"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
@ -38,7 +38,7 @@ func TestVolumePruneErrors(t *testing.T) {
|
|||||||
"force": "true",
|
"force": "true",
|
||||||
},
|
},
|
||||||
volumePruneFunc: func(args filters.Args) (volume.PruneReport, error) {
|
volumePruneFunc: func(args filters.Args) (volume.PruneReport, error) {
|
||||||
return volume.PruneReport{}, errors.Errorf("error pruning volumes")
|
return volume.PruneReport{}, errors.New("error pruning volumes")
|
||||||
},
|
},
|
||||||
expectedError: "error pruning volumes",
|
expectedError: "error pruning volumes",
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package volume
|
package volume
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ func TestVolumeRemoveErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
args: []string{"nodeID"},
|
args: []string{"nodeID"},
|
||||||
volumeRemoveFunc: func(volumeID string, force bool) error {
|
volumeRemoveFunc: func(volumeID string, force bool) error {
|
||||||
return errors.Errorf("error removing the volume")
|
return errors.New("error removing the volume")
|
||||||
},
|
},
|
||||||
expectedError: "error removing the volume",
|
expectedError: "error removing the volume",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user