Skip to content

Commit

Permalink
Simplify setup for testing test_scanpipe_pipes_scancode_extract_archi…
Browse files Browse the repository at this point in the history
…ve_vmimage_qcow2 #367

Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed Dec 3, 2021
1 parent 0d22f1a commit 4eaf91d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
run: docker-compose up -d

- name: Run tests
run: docker-compose run web python ./manage.py test --verbosity=2 --noinput
run: docker-compose run -e FROM_DOCKER_IMAGE=1 web python ./manage.py test --verbosity=2 --noinput
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install libguestfs-tools
run: sudo apt-get update && sudo apt-get install -y libguestfs-tools

- name: Make kernel files executable (reuired for vmimage extraction)
run: sudo chmod 0644 /boot/vmlinuz-*

- name: Install dependencies
run: make dev envfile

Expand Down
15 changes: 13 additions & 2 deletions scanpipe/tests/test_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import collections
import json
import os
import shutil
import tempfile
from pathlib import Path
Expand Down Expand Up @@ -274,8 +275,10 @@ def test_scanpipe_pipes_scancode_extract_archive_vmimage_qcow2(self):
input_location = Path(target) / "foobar.qcow2"

errors = scancode.extract_archive(input_location, target)
from_docker_image = os.environ.get("FROM_DOCKER_IMAGE")

if on_linux:
# The VM image extraction features are available in the Docker image context.
if from_docker_image:
self.assertEqual([], errors)
results = [path.name for path in list(Path(target).glob("**/*"))]
expected = [
Expand All @@ -290,7 +293,15 @@ def test_scanpipe_pipes_scancode_extract_archive_vmimage_qcow2(self):
self.assertEqual(sorted(expected), sorted(results))

else:
self.assertEqual(["VM Image extraction only supported on Linux."], errors)
error = errors[0]
self.assertTrue(
any(
[
"Unable to read kernel" in error,
"VM Image extraction only supported on Linux." in error,
]
)
)

def test_scanpipe_pipes_scancode_get_resource_info(self):
input_location = str(self.data_location / "notice.NOTICE")
Expand Down

0 comments on commit 4eaf91d

Please sign in to comment.