This commit is contained in:
Christian Risi 2025-05-15 11:56:38 +02:00
commit b2cc65ef2c
3 changed files with 41 additions and 0 deletions

5
.pypirc Normal file
View File

@ -0,0 +1,5 @@
[distutils]
index_servers =
private-gitea
[private-gitea]

0
tests/__init__.py Normal file
View File

View File

@ -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