mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Remove validationError type, and use errdefs.InvalidParameter
Using `errors.Errorf()` passes the error with the stack trace for debugging purposes. Also using `errdefs.InvalidParameter` for Windows, so that the API will return a 4xx status, instead of a 5xx, and added tests for both validations. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -1828,8 +1828,55 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
|
||||
}...)
|
||||
}
|
||||
|
||||
if DaemonIsWindows() {
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
config: containertypes.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "not-supported-on-windows",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"type": "tmpfs"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: `options are not supported on this platform`,
|
||||
},
|
||||
}...)
|
||||
}
|
||||
|
||||
if DaemonIsLinux() {
|
||||
cases = append(cases, []testCase{
|
||||
{
|
||||
config: containertypes.Config{
|
||||
Image: "busybox",
|
||||
},
|
||||
hostConfig: containertypes.HostConfig{
|
||||
Mounts: []mounttypes.Mount{
|
||||
{
|
||||
Type: "volume",
|
||||
Source: "missing-device-opt",
|
||||
Target: destPath,
|
||||
VolumeOptions: &mounttypes.VolumeOptions{
|
||||
DriverConfig: &mounttypes.Driver{
|
||||
Name: "local",
|
||||
Options: map[string]string{"foobar": "foobaz"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: `invalid option: "foobar"`,
|
||||
},
|
||||
{
|
||||
config: containertypes.Config{
|
||||
Image: "busybox",
|
||||
@ -1935,6 +1982,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cli.Close()
|
||||
|
||||
// TODO add checks for statuscode returned by API
|
||||
for i, x := range cases {
|
||||
c.Logf("case %d", i)
|
||||
_, err = cli.ContainerCreate(context.Background(), &x.config, &x.hostConfig, &networktypes.NetworkingConfig{}, "")
|
||||
|
Reference in New Issue
Block a user