Pārlūkot izejas kodu

Add test to verify objects stored in MemoryObjectStore can not be lost when they are modified.

Félix Mattrat 9 gadi atpakaļ
vecāks
revīzija
dc5d21e3d3
1 mainītis faili ar 14 papildinājumiem un 0 dzēšanām
  1. 14 0
      dulwich/tests/test_object_store.py

+ 14 - 0
dulwich/tests/test_object_store.py

@@ -87,6 +87,20 @@ class ObjectStoreTests(object):
         # access to a serialized form.
         self.store.add_objects([])
 
+    def test_store_resilience(self):
+        """Test if updating an existing stored object doesn't erase the
+        object from the store.
+        """
+        test_object = make_object(Blob, data=b'data')
+
+        self.store.add_object(test_object)
+        test_object_id = test_object.id
+        test_object.data = test_object.data + b'update'
+        stored_test_object = self.store[test_object_id]
+
+        self.assertNotEqual(test_object.id, stored_test_object.id)
+        self.assertEqual(stored_test_object.id, test_object_id)
+
     def test_add_object(self):
         self.store.add_object(testobject)
         self.assertEqual(set([testobject.id]), set(self.store))