initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
36
buildman/component/test/test_buildcomponent.py
Normal file
36
buildman/component/test/test_buildcomponent.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
import pytest
|
||||
|
||||
from buildman.component.buildcomponent import BuildComponent
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected_path,expected_file', [
|
||||
("", "/", "Dockerfile"),
|
||||
("/", "/", "Dockerfile"),
|
||||
("/Dockerfile", "/", "Dockerfile"),
|
||||
("/server.Dockerfile", "/", "server.Dockerfile"),
|
||||
("/somepath", "/somepath", "Dockerfile"),
|
||||
("/somepath/", "/somepath", "Dockerfile"),
|
||||
("/somepath/Dockerfile", "/somepath", "Dockerfile"),
|
||||
("/somepath/server.Dockerfile", "/somepath", "server.Dockerfile"),
|
||||
("/somepath/some_other_path", "/somepath/some_other_path", "Dockerfile"),
|
||||
("/somepath/some_other_path/", "/somepath/some_other_path", "Dockerfile"),
|
||||
("/somepath/some_other_path/Dockerfile", "/somepath/some_other_path", "Dockerfile"),
|
||||
("/somepath/some_other_path/server.Dockerfile", "/somepath/some_other_path", "server.Dockerfile"),
|
||||
])
|
||||
def test_path_is_dockerfile(input, expected_path, expected_file):
|
||||
actual_path, actual_file = BuildComponent.name_and_path(input)
|
||||
assert actual_path == expected_path
|
||||
assert actual_file == expected_file
|
||||
|
||||
@pytest.mark.parametrize('build_config,context,dockerfile_path', [
|
||||
({}, '', ''),
|
||||
({'build_subdir': '/builddir/Dockerfile'}, '', '/builddir/Dockerfile'),
|
||||
({'context': '/builddir'}, '/builddir', ''),
|
||||
({'context': '/builddir', 'build_subdir': '/builddir/Dockerfile'}, '/builddir', 'Dockerfile'),
|
||||
({'context': '/some_other_dir/Dockerfile', 'build_subdir': '/builddir/Dockerfile'}, '/builddir', 'Dockerfile'),
|
||||
({'context': '/', 'build_subdir':'Dockerfile'}, '/', 'Dockerfile')
|
||||
])
|
||||
def test_extract_dockerfile_args(build_config, context, dockerfile_path):
|
||||
actual_context, actual_dockerfile_path = BuildComponent.extract_dockerfile_args(build_config)
|
||||
assert context == actual_context
|
||||
assert dockerfile_path == actual_dockerfile_path
|
16
buildman/component/test/test_buildparse.py
Normal file
16
buildman/component/test/test_buildparse.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
import pytest
|
||||
|
||||
from buildman.component.buildparse import extract_current_step
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected_step', [
|
||||
("", None),
|
||||
("Step a :", None),
|
||||
("Step 1 :", 1),
|
||||
("Step 1 : ", 1),
|
||||
("Step 1/2 : ", 1),
|
||||
("Step 2/17 : ", 2),
|
||||
("Step 4/13 : ARG somearg=foo", 4),
|
||||
])
|
||||
def test_extract_current_step(input, expected_step):
|
||||
assert extract_current_step(input) == expected_step
|
Reference in a new issue