Bläddra i källkod

Add some more tests.

Jelmer Vernooij 4 år sedan
förälder
incheckning
e1ce260118
1 ändrade filer med 27 tillägg och 0 borttagningar
  1. 27 0
      dulwich/tests/test_merge.py

+ 27 - 0
dulwich/tests/test_merge.py

@@ -62,6 +62,33 @@ class MergeTests(TestCase):
         conflicts = merge(self.repo1, [cid2])
         self.assertEqual([], conflicts)
 
+    def test_fast_forward(self):
+        # Other tree is ahead of us
+        cid1 = self.common_cid
+        cid2 = self._add_file(self.repo2, 'c')
+        self.repo2.fetch(self.repo1)
+        self.assertEqual(cid1, self.repo1.head())
+        conflicts = merge(self.repo1, [cid2])
+        self.assertEqual([], conflicts)
+
+    def test_already_ahead(self):
+        # We're ahead of the other tree
+        cid1 = self._add_file(self.repo1, 'b')
+        cid2 = self.common_cid
+        self.repo2.fetch(self.repo1)
+        self.assertEqual(cid1, self.repo1.head())
+        conflicts = merge(self.repo1, [cid2])
+        self.assertEqual([], conflicts)
+
+    def test_changed(self):
+        # Two trees both add a new file
+        cid1 = self._add_file(self.repo1, 'a', contents='a new line\n')
+        cid2 = self._add_file(self.repo2, 'c')
+        self.repo2.fetch(self.repo1)
+        self.assertEqual(cid1, self.repo1.head())
+        conflicts = merge(self.repo1, [cid2])
+        self.assertEqual([], conflicts)
+
 
 class FindMergeBaseTests(TestCase):