afbd6fb19b
some errors were introduced with file paths of the form "/some_path/some_other_path" as "some_other_path" would be the dockerfile name
23 lines
1 KiB
Python
23 lines
1 KiB
Python
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
|