diff --git a/.pypirc b/.pypirc new file mode 100644 index 0000000..ffbde51 --- /dev/null +++ b/.pypirc @@ -0,0 +1,5 @@ +[distutils] +index_servers = + private-gitea + +[private-gitea] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit-tests/instruction_test.py b/tests/unit-tests/instruction_test.py new file mode 100644 index 0000000..691b4fa --- /dev/null +++ b/tests/unit-tests/instruction_test.py @@ -0,0 +1,36 @@ +# content of test_sample.py +from pathlib import Path +import re +import pytest +import docktoranalyzer +import docktoranalyzer.dockerfile +from docktoranalyzer.dockerfile.docker_constants import DockerConstants +from docktoranalyzer.dockerfile.dockerfile_parser import DockerFileParser + +# TODO: use a glob to take files and rege +@pytest.fixture +def docker_file_arrays(): + + # I need to count one stage over to account for instructions + # the first FROM + return [ + {"path": "./assets/dockerfiles/binary.dockerfile", "stages": 2}, + {"path": "./assets/dockerfiles/crypto.dockerfile", "stages": 2}, + {"path": "./assets/dockerfiles/web.dockerfile", "stages": 3}, + {"path": "./assets/dockerfiles/with-chunks.dockerfile", "stages": 3}, + ] + + +# TODO: Make tests for regex + + +def test_dockerfile_parser(docker_file_arrays): + + for docker_file_info in docker_file_arrays: + + docker_path = docker_file_info["path"] + actual_stages = docker_file_info["stages"] + + docker = DockerFileParser.dockerfile_factory(Path(docker_path)) + + assert len(docker.stages) == actual_stages