Skip to content

Commit fad84c3

Browse files
committed
integration: test_create_volume_invalid_driver allow either 400 or 404
The API currently returns a 404 error when trying to create a volume with an invalid (non-existing) driver. We are considering changing this status code to be a 400 (invalid parameter), as even though the _reason_ of the error may be that the plugin / driver is not found, the _cause_ of the error is that the user provided a plugin / driver that's invalid for the engine they're connected to. This patch updates the test to pass for either case. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 03e43be commit fad84c3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/integration/api_volume_test.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ def test_create_volume(self):
1717
assert result['Driver'] == 'local'
1818

1919
def test_create_volume_invalid_driver(self):
20-
driver_name = 'invalid.driver'
20+
# special name to avoid exponential timeout loop
21+
# https://github.com/moby/moby/blob/9e00a63d65434cdedc444e79a2b33a7c202b10d8/pkg/plugins/client.go#L253-L254
22+
driver_name = 'this-plugin-does-not-exist'
2123

22-
with pytest.raises(docker.errors.NotFound):
24+
with pytest.raises(docker.errors.APIError) as cm:
2325
self.client.create_volume('perfectcherryblossom', driver_name)
26+
assert (
27+
cm.value.response.status_code == 404 or
28+
cm.value.response.status_code == 400
29+
)
2430

2531
def test_list_volumes(self):
2632
name = 'imperishablenight'

0 commit comments

Comments
 (0)