adding test and more informative error

pull/300/head
Chris Holdgraf 2018-04-24 16:51:39 -07:00
rodzic 3ceb1fb39c
commit 8c22e42ee4
2 zmienionych plików z 14 dodań i 4 usunięć

Wyświetl plik

@ -177,7 +177,8 @@ class Repo2Docker(Application):
if ref:
if len(ref.split('/')) != 2:
raise ValueError('--ref must be of the form remote/ref')
raise ValueError('Expected --ref to be of the form '
'remote/reference, but got %s' % ref)
try:
for line in execute_cmd(['git', 'reset', '--hard', ref],
cwd=checkout_path,
@ -247,8 +248,8 @@ class Repo2Docker(Application):
argparser.add_argument(
'--ref',
help=('If building a git url, which ref to check out. Must be of'
'the form `remote/ref`. E.g., `origin/master`.')
help=('If building a git url, which reference to check out. Must '
'be of the form `remote/reference`. E.g., `origin/master`.')
)
argparser.add_argument(

Wyświetl plik

@ -138,7 +138,7 @@ def test_volume_no_run_fail():
def test_env_no_run_fail():
"""
Test to check if repo2docker fails when both --no-run and -e arguments are given
Test to check if repo2docker fails when both --no-run and -e arguments are given
"""
builddir = os.path.dirname(__file__)
args_list = ['--no-run', '-e', 'FOO=bar', '--']
@ -231,3 +231,12 @@ def test_docker_no_build_success():
assert validate_arguments(builddir, args_list, "", True)
def test_ref_has_correct_form():
"""
Test to check if --ref is given with the form `remote/reference`
"""
builddir = os.path.dirname(__file__)
args_list = ['--no-run', '--no-build', '--ref', 'myreference']
assert not validate_arguments(builddir, args_list, 'Expected --ref to be of the form remote/reference, but got myreference')