summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo_tests.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-13 18:56:35 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-09-13 18:57:17 +0100
commit9c786c1ec409724f1331c0fec5ba7a0e98732e24 (patch)
tree46295306079710d9a1d70b867448b7669b3b4548 /morphlib/cachedrepo_tests.py
parent9e95e4a72d875d201dfdb012f217181788eec7f1 (diff)
downloadmorph-9c786c1ec409724f1331c0fec5ba7a0e98732e24.tar.gz
Give more useful errors when cloning from local cache fails
Diffstat (limited to 'morphlib/cachedrepo_tests.py')
-rw-r--r--morphlib/cachedrepo_tests.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py
index 14c5daac..7c6781c6 100644
--- a/morphlib/cachedrepo_tests.py
+++ b/morphlib/cachedrepo_tests.py
@@ -80,14 +80,10 @@ class CachedRepoTests(unittest.TestCase):
pass
def checkout_ref(self, ref, target_dir):
- bad_refs = [
- 'a4da32f5a81c8bc6d660404724cedc3bc0914a75',
- '079bbfd447c8534e464ce5d40b80114c2022ebf4',
- ]
- if ref in bad_refs:
- # simulate a git failure or something similar to
- # trigger a CheckoutError
- raise cliapp.AppException('git checkout %s' % ref)
+ if ref == 'a4da32f5a81c8bc6d660404724cedc3bc0914a75':
+ raise morphlib.cachedrepo.CloneError(self.repo, target_dir)
+ elif ref == '079bbfd447c8534e464ce5d40b80114c2022ebf4':
+ raise morphlib.cachedrepo.CheckoutError(self.repo, ref, target_dir)
else:
with open(os.path.join(target_dir, 'foo.morph'), 'w') as f:
f.write('contents of foo.morph')
@@ -186,6 +182,11 @@ class CachedRepoTests(unittest.TestCase):
'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
self.tempdir.dirname)
+ def test_fail_checkout_due_to_clone_error(self):
+ self.assertRaises(cachedrepo.CloneError, self.repo.checkout,
+ 'a4da32f5a81c8bc6d660404724cedc3bc0914a75',
+ self.tempdir.join('failed-checkout'))
+
def test_fail_checkout_from_invalid_ref(self):
self.assertRaises(cachedrepo.CheckoutError, self.repo.checkout,
'079bbfd447c8534e464ce5d40b80114c2022ebf4',
@@ -200,11 +201,6 @@ class CachedRepoTests(unittest.TestCase):
morph_filename = os.path.join(unpack_dir, 'foo.morph')
self.assertTrue(os.path.exists(morph_filename))
- def test_fail_checkout_due_to_copy_or_checkout_problem(self):
- self.assertRaises(cachedrepo.CheckoutError, self.repo.checkout,
- 'a4da32f5a81c8bc6d660404724cedc3bc0914a75',
- self.tempdir.join('failed-checkout'))
-
def test_ls_tree_in_existing_ref(self):
data = self.repo.ls_tree('e28a23812eadf2fce6583b8819b9c5dbd36b9fb9')
self.assertEqual(data, ['foo.morph'])