@@ -3338,13 +3338,25 @@ class TestDockerCompose(_CheckTestBase):
3338
3338
3339
3339
check_group = "xr-compose"
3340
3340
check_name = "docker-compose"
3341
- cmds = ["docker-compose --version" ]
3341
+ cmds = ["docker compose version" , "docker -compose --version" ]
3342
3342
3343
- def test_success (self , capsys ):
3343
+ def test_success_plugin (self , capsys ):
3344
3344
"""Test the success case."""
3345
- result , output = self .perform_check (
3346
- capsys , cmd_effects = "docker-compose version 1.18.0"
3345
+ cmd_effects = ["Docker Compose version v2.19.0" , None ]
3346
+ result , output = self .perform_check (capsys , cmd_effects = cmd_effects )
3347
+ assert (
3348
+ textwrap .dedent (output )
3349
+ == "PASS -- docker-compose (version 2.19.0)\n "
3347
3350
)
3351
+ assert result is CheckState .SUCCESS
3352
+
3353
+ def test_success_standalone (self , capsys ):
3354
+ """Test the success case."""
3355
+ cmd_effects = [
3356
+ subprocess .SubprocessError ,
3357
+ "docker-compose version 1.18.0" ,
3358
+ ]
3359
+ result , output = self .perform_check (capsys , cmd_effects = cmd_effects )
3348
3360
assert (
3349
3361
textwrap .dedent (output )
3350
3362
== "PASS -- docker-compose (version 1.18.0)\n "
@@ -3353,13 +3365,12 @@ def test_success(self, capsys):
3353
3365
3354
3366
def test_subproc_error (self , capsys ):
3355
3367
"""Test a subprocess error being raised."""
3356
- result , output = self .perform_check (
3357
- capsys , cmd_effects = subprocess .SubprocessError
3358
- )
3368
+ cmd_effects = [subprocess .SubprocessError , subprocess .SubprocessError ]
3369
+ result , output = self .perform_check (capsys , cmd_effects = cmd_effects )
3359
3370
assert textwrap .dedent (output ) == textwrap .dedent (
3360
3371
"""\
3361
3372
FAIL -- docker-compose
3362
- Docker Compose not found (checked with 'docker-compose --version').
3373
+ Docker Compose not found (checked with 'docker compose version' and 'docker -compose --version').
3363
3374
Launching XRd topologies with xr-compose requires docker-compose.
3364
3375
See installation instructions at https://docs.docker.com/compose/install/.
3365
3376
"""
@@ -3368,9 +3379,8 @@ def test_subproc_error(self, capsys):
3368
3379
3369
3380
def test_no_version_match (self , capsys ):
3370
3381
"""Test failure to match the version in the output."""
3371
- result , output = self .perform_check (
3372
- capsys , cmd_effects = "unexpected output"
3373
- )
3382
+ cmd_effects = ["unexpected output" , None ]
3383
+ result , output = self .perform_check (capsys , cmd_effects = cmd_effects )
3374
3384
assert textwrap .dedent (output ) == textwrap .dedent (
3375
3385
"""\
3376
3386
ERROR -- docker-compose
@@ -3381,9 +3391,11 @@ def test_no_version_match(self, capsys):
3381
3391
3382
3392
def test_old_version (self , capsys ):
3383
3393
"""Test the version being too old."""
3384
- result , output = self .perform_check (
3385
- capsys , cmd_effects = "docker-compose version 1.17.10"
3386
- )
3394
+ cmd_effects = [
3395
+ subprocess .SubprocessError ,
3396
+ "docker-compose version 1.17.10" ,
3397
+ ]
3398
+ result , output = self .perform_check (capsys , cmd_effects = cmd_effects )
3387
3399
assert textwrap .dedent (output ) == textwrap .dedent (
3388
3400
"""\
3389
3401
FAIL -- docker-compose
@@ -3395,9 +3407,8 @@ def test_old_version(self, capsys):
3395
3407
3396
3408
def test_unexpected_error (self , capsys ):
3397
3409
"""Test unexpected error being raised."""
3398
- result , output = self .perform_check (
3399
- capsys , cmd_effects = Exception ("test exception" )
3400
- )
3410
+ cmd_effects = [Exception ("test exception" ), None ]
3411
+ result , output = self .perform_check (capsys , cmd_effects = cmd_effects )
3401
3412
assert textwrap .dedent (output ) == textwrap .dedent (
3402
3413
"""\
3403
3414
ERROR -- docker-compose
0 commit comments