diff --git a/tests/unit/test_container_to_build_args.py b/tests/unit/test_container_to_build_args.py index 885d69c..cd52aca 100644 --- a/tests/unit/test_container_to_build_args.py +++ b/tests/unit/test_container_to_build_args.py @@ -180,3 +180,42 @@ class TestContainerToBuildArgs(unittest.TestCase): for c in cleanup_callbacks: c() self.assertFalse(os.path.exists(temp_dockerfile)) + + def test_context_git_url(self): + c = create_compose_mock() + + cnt = get_minimal_container() + cnt['build']['context'] = "https://github.com/test_repo.git" + args = get_minimal_args() + + args = container_to_build_args(c, cnt, args, lambda path: False) + self.assertEqual( + args, + [ + '-t', + 'new-image', + '--no-cache', + '--pull-always', + 'https://github.com/test_repo.git', + ], + ) + + def test_context_invalid_git_url_git_is_not_prefix(self): + c = create_compose_mock() + + cnt = get_minimal_container() + cnt['build']['context'] = "not_prefix://github.com/test_repo" + args = get_minimal_args() + + with self.assertRaises(OSError): + container_to_build_args(c, cnt, args, lambda path: False) + + def test_context_invalid_git_url_git_is_not_suffix(self): + c = create_compose_mock() + + cnt = get_minimal_container() + cnt['build']['context'] = "https://github.com/test_repo.git/not_suffix" + args = get_minimal_args() + + with self.assertRaises(OSError): + container_to_build_args(c, cnt, args, lambda path: False)