kopia lustrzana https://github.com/jupyterhub/repo2docker
adding test and more informative error
rodzic
3ceb1fb39c
commit
8c22e42ee4
|
@ -177,7 +177,8 @@ class Repo2Docker(Application):
|
||||||
|
|
||||||
if ref:
|
if ref:
|
||||||
if len(ref.split('/')) != 2:
|
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:
|
try:
|
||||||
for line in execute_cmd(['git', 'reset', '--hard', ref],
|
for line in execute_cmd(['git', 'reset', '--hard', ref],
|
||||||
cwd=checkout_path,
|
cwd=checkout_path,
|
||||||
|
@ -247,8 +248,8 @@ class Repo2Docker(Application):
|
||||||
|
|
||||||
argparser.add_argument(
|
argparser.add_argument(
|
||||||
'--ref',
|
'--ref',
|
||||||
help=('If building a git url, which ref to check out. Must be of'
|
help=('If building a git url, which reference to check out. Must '
|
||||||
'the form `remote/ref`. E.g., `origin/master`.')
|
'be of the form `remote/reference`. E.g., `origin/master`.')
|
||||||
)
|
)
|
||||||
|
|
||||||
argparser.add_argument(
|
argparser.add_argument(
|
||||||
|
|
|
@ -138,7 +138,7 @@ def test_volume_no_run_fail():
|
||||||
|
|
||||||
def test_env_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__)
|
builddir = os.path.dirname(__file__)
|
||||||
args_list = ['--no-run', '-e', 'FOO=bar', '--']
|
args_list = ['--no-run', '-e', 'FOO=bar', '--']
|
||||||
|
@ -231,3 +231,12 @@ def test_docker_no_build_success():
|
||||||
|
|
||||||
assert validate_arguments(builddir, args_list, "", True)
|
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')
|
||||||
|
|
Ładowanie…
Reference in New Issue