Browse Source

Add unittest for issue del ref (issue #108)

Add a test for _apply_pack of ReceivePackHandler
in order to test deleting a ref.

Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Fabien Boucher 11 years ago
parent
commit
eae1bc9d16
1 changed files with 24 additions and 1 deletions
  1. 24 1
      dulwich/tests/test_server.py

+ 24 - 1
dulwich/tests/test_server.py

@@ -50,7 +50,9 @@ from dulwich.tests import TestCase
 from dulwich.tests.utils import (
     make_commit,
     )
-
+from dulwich.protocol import (
+    ZERO_SHA,
+    )
 
 ONE = '1' * 40
 TWO = '2' * 40
@@ -200,6 +202,27 @@ class TestUploadPackHandler(UploadPackHandler):
     def required_capabilities(self):
         return ()
 
+class ReceivePackHandlerTestCase(TestCase):
+
+    def setUp(self):
+        super(ReceivePackHandlerTestCase, self).setUp()
+        self._repo = MemoryRepo.init_bare([], {})
+        backend = DictBackend({'/': self._repo})
+        self._handler = ReceivePackHandler(
+          backend, ['/', 'host=lolcathost'], TestProto())
+
+    def test_apply_pack_del_ref(self):
+        refs = {
+            'refs/heads/master': TWO,
+            'refs/heads/fake-branch': ONE}
+        self._repo.refs._update(refs)
+        update_refs = [[ONE, ZERO_SHA, 'refs/heads/fake-branch'], ]
+        status = self._handler._apply_pack(update_refs)
+        self.assertEqual(status[0][0], 'unpack')
+        self.assertEqual(status[0][1], 'ok')
+        self.assertEqual(status[1][0], 'refs/heads/fake-branch')
+        self.assertEqual(status[1][1], 'ok')
+
 
 class ProtocolGraphWalkerTestCase(TestCase):