From 769efb8a69dc86ee0a0bdeea5d640868745da155 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Wed, 12 Dec 2018 23:32:50 -0800 Subject: [PATCH] Add test for proper failure when ref isn't found in git repo --- tests/contentproviders/test_git.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/contentproviders/test_git.py b/tests/contentproviders/test_git.py index eff5e3d9..023e2e49 100644 --- a/tests/contentproviders/test_git.py +++ b/tests/contentproviders/test_git.py @@ -1,6 +1,7 @@ from contextlib import contextmanager import os import subprocess +import pytest from tempfile import TemporaryDirectory from repo2docker.contentproviders import Git @@ -34,6 +35,16 @@ def test_clone(): pass assert os.path.exists(os.path.join(clone_dir, 'test')) +def test_bad_ref(): + """ + Test trying to checkout a ref that doesn't exist + """ + with git_repo() as upstream: + with TemporaryDirectory() as clone_dir: + spec = {'repo': upstream, 'ref': 'does-not-exist'} + with pytest.raises(ValueError): + for _ in Git().fetch(spec, clone_dir): + pass def test_always_accept(): # The git content provider should always accept a spec