浏览代码

Add test for repeated repacking.

Jelmer Vernooij 7 年之前
父节点
当前提交
159b36446b
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      dulwich/tests/test_object_store.py

+ 19 - 0
dulwich/tests/test_object_store.py

@@ -299,6 +299,25 @@ class PackBasedObjectStoreTests(ObjectStoreTests):
         self.assertEqual(1, len(self.store.packs))
         self.assertEqual(0, self.store.pack_loose_objects())
 
+    def test_repack_existing(self):
+        b1 = make_object(Blob, data=b"yummy data")
+        self.store.add_object(b1)
+        b2 = make_object(Blob, data=b"more yummy data")
+        self.store.add_object(b2)
+        self.store.add_objects([(b1, None), (b2, None)])
+        self.store.add_objects([(b2, None)])
+        self.assertEqual({b1.id, b2.id}, set(self.store))
+        self.assertEqual(2, len(self.store.packs))
+        self.assertEqual(2, self.store.repack())
+        self.assertEqual(1, len(self.store.packs))
+        self.assertEqual(0, self.store.pack_loose_objects())
+
+        self.assertEqual({b1.id, b2.id}, set(self.store))
+        self.assertEqual(1, len(self.store.packs))
+        self.assertEqual(2, self.store.repack())
+        self.assertEqual(1, len(self.store.packs))
+        self.assertEqual(0, self.store.pack_loose_objects())
+
 
 class DiskObjectStoreTests(PackBasedObjectStoreTests, TestCase):