add tests for get_old_revs.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 15 Nov 2010 01:29:36 +0000 (02:29 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 15 Nov 2010 01:29:36 +0000 (02:29 +0100)
buildfarm/data.py
buildfarm/tests/test_data.py

index 36c342405a6a49e7b2c1944e7eeb6f25034b0c40..5c5f86c37cc000100bd70aa82b57b1adcc223e63 100644 (file)
@@ -203,6 +203,9 @@ class Build(object):
         self.compiler = compiler
         self.commit_revision = self.revision = rev
 
+    def __eq__(self, other):
+        return (self.log_checksum() == other.log_checksum())
+
     def __repr__(self):
         if self.revision is not None:
             return "<%s: revision %s of %s on %s using %s>" % (self.__class__.__name__, self.revision, self.tree, self.host, self.compiler)
index e79224bf24dac2ab21b4b7506a08be4b6180c31b..c8d50f47835ecf48239ba71bcae4b5ed9ff03296 100755 (executable)
@@ -140,6 +140,30 @@ BUILD COMMIT REVISION: myrev
     def test_get_latest_revision_none(self):
         self.assertRaises(data.NoSuchBuildError, self.x.get_latest_revision, "tdb", "charis", "cc")
 
+    def test_get_old_revs_none(self):
+        self.assertEquals([],
+            list(self.x.get_old_revs(u"tdb", u"charis", u"gcc")))
+
+    def test_get_old_revs(self):
+        path = self.create_mock_logfile("tdb", "charis", "cc",
+            contents="""
+BUILD COMMIT REVISION: 12
+""")
+        build = data.Build(path[:-4], "tdb", "charis", "cc")
+        b1 = self.x.upload_build(build)
+        path = self.create_mock_logfile("tdb", "charis", "cc",
+            contents="""
+BUILD COMMIT REVISION: 15
+""")
+        build = data.Build(path[:-4], "tdb", "charis", "cc")
+        b2 = self.x.upload_build(build)
+        path = self.create_mock_logfile("tdb", "charis", "cc",
+            contents="""
+BUILD COMMIT REVISION: 15
+""")
+        self.assertEquals([b1, b2],
+            list(self.x.get_old_revs(u"tdb", u"charis", u"cc")))
+
 
 class BuildResultStoreTests(BuildFarmTestCase,BuildResultStoreTestBase):