Skip to content

Commit

Permalink
Tests: Add test_03_destroy_release
Browse files Browse the repository at this point in the history
  • Loading branch information
Defenso-QTH authored Sep 24, 2024
1 parent e9b8045 commit d51e200
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/functional_tests/0098_destroy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,19 @@ def test_02_destroy_jails(invoke_cli, resource_selector, skip_test):
assert jail.exists is False


@require_root
@require_zpool
def test_03_destroy_release(invoke_cli, skip_test, resource_selector):
releases = resource_selector.releases
skip_test(not releases)

release = releases[0]
assert release.exists is True

invoke_cli(

Check failure on line 74 in tests/functional_tests/0098_destroy_test.py

View check run for this annotation

Cirrus CI / Custom prefix

tests/functional_tests/0098_destroy_test.py#L74

tests.functional_tests.0098_destroy_test.test_03_destroy_release
Raw output
invoke_cli = <function invoke_cli.<locals>.invoke at 0x2ea6dd234b80>
skip_test = <function skip_test.<locals>.skip at 0x2ea6dd234d60>
resource_selector = <tests.data_classes.ResourceSelector object at 0x2ea6dcfb1910>

    @require_root
    @require_zpool
    def test_03_destroy_release(invoke_cli, skip_test, resource_selector):
        releases = resource_selector.releases
        skip_test(not releases)
    
        release = releases[0]
        assert release.exists is True
    
>       invoke_cli(
            ['destroy', '-fr', release]
        )

tests/functional_tests/0098_destroy_test.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cmd = ['iocage', 'destroy', '-fr', '14.1-RELEASE']
reason = "jail '  b5065831\n' not found!\n", assert_returncode = True

    def invoke(cmd, reason=None, assert_returncode=True):
        cmd.insert(0, 'iocage')
        cmd = [str(c) for c in cmd]
    
        result = subprocess.run(
            cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
        reason = f'{reason}: {result.stderr}' if reason else result.stderr
    
        if assert_returncode:
            # Empty or Template jails that should not be started/stopped but
            # sometimes make it in due to a race
            try:
                reason = reason.decode()
            except AttributeError:
                pass
    
            if 'execvp: /bin/sh: No such' not in reason:
>               assert result.returncode == 0, reason
E               AssertionError: jail '  b5065831
E                 ' not found!
E                 
E               assert 1 == 0
E                +  where 1 = CompletedProcess(args=['iocage', 'destroy', '-fr', '14.1-RELEASE'], returncode=1, stdout=b'', stderr=b"jail '  b5065831\n' not found!\n").returncode

tests/conftest.py:288: AssertionError

Check failure on line 74 in tests/functional_tests/0098_destroy_test.py

View check run for this annotation

Cirrus CI / No prefix

tests/functional_tests/0098_destroy_test.py#L74

tests.functional_tests.0098_destroy_test.test_03_destroy_release
Raw output
invoke_cli = <function invoke_cli.<locals>.invoke at 0x3d815e7914e0>
skip_test = <function skip_test.<locals>.skip at 0x3d815e790720>
resource_selector = <tests.data_classes.ResourceSelector object at 0x3d815e823110>

    @require_root
    @require_zpool
    def test_03_destroy_release(invoke_cli, skip_test, resource_selector):
        releases = resource_selector.releases
        skip_test(not releases)
    
        release = releases[0]
        assert release.exists is True
    
>       invoke_cli(
            ['destroy', '-fr', release]
        )

tests/functional_tests/0098_destroy_test.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cmd = ['iocage', 'destroy', '-fr', '14.1-RELEASE']
reason = "jail '  8c73afbc-4c2e-4b74-82dc-97a3dbf86d11\n' not found!\n"
assert_returncode = True

    def invoke(cmd, reason=None, assert_returncode=True):
        cmd.insert(0, 'iocage')
        cmd = [str(c) for c in cmd]
    
        result = subprocess.run(
            cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
        reason = f'{reason}: {result.stderr}' if reason else result.stderr
    
        if assert_returncode:
            # Empty or Template jails that should not be started/stopped but
            # sometimes make it in due to a race
            try:
                reason = reason.decode()
            except AttributeError:
                pass
    
            if 'execvp: /bin/sh: No such' not in reason:
>               assert result.returncode == 0, reason
E               AssertionError: jail '  8c73afbc-4c2e-4b74-82dc-97a3dbf86d11
E                 ' not found!
E                 
E               assert 1 == 0
E                +  where 1 = CompletedProcess(args=['iocage', 'destroy', '-fr', '14.1-RELEASE'], returncode=1, stdout=b'', stderr=b"jail '  8c73afbc-4c2e-4b74-82dc-97a3dbf86d11\n' not found!\n").returncode

tests/conftest.py:288: AssertionError
['destroy', '-fr', release]
)

assert release.exists is False

# TODO: Add tests for release and download later - fetching is time consuming :P

0 comments on commit d51e200

Please sign in to comment.