| Index: third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
|
| diff --git a/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py b/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
|
| index a6d4253cae43572992eac8d73b24cead97f63d9e..d28bcc61a72fd875af51c533b4ae189172225041 100644
|
| --- a/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
|
| +++ b/third_party/buildbot_8_4p1/buildbot/test/unit/test_db_buildsets.py
|
| @@ -441,3 +441,91 @@ class TestBuildsetsConnectorComponent(
|
| d.addCallbacks(cb, eb)
|
| return d
|
|
|
| + def insert_test_getRecentBuildsets_data(self):
|
| + return self.insertTestData([
|
| + fakedb.Change(changeid=91, branch='branch_a', repository='repo_a'),
|
| + fakedb.SourceStamp(id=91, branch='branch_a', repository='repo_a'),
|
| + fakedb.SourceStampChange(sourcestampid=91, changeid=91),
|
| +
|
| + fakedb.Buildset(id=91, sourcestampid=91, complete=0,
|
| + complete_at=298297875, results=-1, submitted_at=266761875,
|
| + external_idstring='extid', reason='rsn1'),
|
| + fakedb.Buildset(id=92, sourcestampid=91, complete=1,
|
| + complete_at=298297876, results=7, submitted_at=266761876,
|
| + external_idstring='extid', reason='rsn2'),
|
| +
|
| + # buildset unrelated to the change
|
| + fakedb.Buildset(id=93, sourcestampid=1, complete=1,
|
| + complete_at=298297877, results=7, submitted_at=266761877,
|
| + external_idstring='extid', reason='rsn2'),
|
| + ])
|
| +
|
| + def test_getRecentBuildsets_all(self):
|
| + d = self.insert_test_getRecentBuildsets_data()
|
| + d.addCallback(lambda _ :
|
| + self.db.buildsets.getRecentBuildsets(2, branch='branch_a',
|
| + repository='repo_a'))
|
| + def check(bsdictlist):
|
| + self.assertEqual(bsdictlist, [
|
| + dict(external_idstring='extid', reason='rsn1', sourcestampid=91,
|
| + submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 15,
|
| + tzinfo=UTC),
|
| + complete_at=datetime.datetime(1979, 6, 15, 12, 31, 15,
|
| + tzinfo=UTC),
|
| + complete=False, results=-1, bsid=91),
|
| + dict(external_idstring='extid', reason='rsn2', sourcestampid=91,
|
| + submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 16,
|
| + tzinfo=UTC),
|
| + complete_at=datetime.datetime(1979, 6, 15, 12, 31, 16,
|
| + tzinfo=UTC),
|
| + complete=True, results=7, bsid=92),
|
| + ])
|
| + d.addCallback(check)
|
| + return d
|
| +
|
| + def test_getRecentBuildsets_one(self):
|
| + d = self.insert_test_getRecentBuildsets_data()
|
| + d.addCallback(lambda _ :
|
| + self.db.buildsets.getRecentBuildsets(1, branch='branch_a',
|
| + repository='repo_a'))
|
| + def check(bsdictlist):
|
| + self.assertEqual(bsdictlist, [
|
| + dict(external_idstring='extid', reason='rsn2', sourcestampid=91,
|
| + submitted_at=datetime.datetime(1978, 6, 15, 12, 31, 16,
|
| + tzinfo=UTC),
|
| + complete_at=datetime.datetime(1979, 6, 15, 12, 31, 16,
|
| + tzinfo=UTC),
|
| + complete=True, results=7, bsid=92),
|
| + ])
|
| + d.addCallback(check)
|
| + return d
|
| +
|
| + def test_getRecentBuildsets_zero(self):
|
| + d = self.insert_test_getRecentBuildsets_data()
|
| + d.addCallback(lambda _ :
|
| + self.db.buildsets.getRecentBuildsets(0, branch='branch_a',
|
| + repository='repo_a'))
|
| + def check(bsdictlist):
|
| + self.assertEqual(bsdictlist, [])
|
| + d.addCallback(check)
|
| + return d
|
| +
|
| + def test_getRecentBuildsets_noBranchMatch(self):
|
| + d = self.insert_test_getRecentBuildsets_data()
|
| + d.addCallback(lambda _ :
|
| + self.db.buildsets.getRecentBuildsets(2, branch='bad_branch',
|
| + repository='repo_a'))
|
| + def check(bsdictlist):
|
| + self.assertEqual(bsdictlist, [])
|
| + d.addCallback(check)
|
| + return d
|
| +
|
| + def test_getRecentBuildsets_noRepoMatch(self):
|
| + d = self.insert_test_getRecentBuildsets_data()
|
| + d.addCallback(lambda _ :
|
| + self.db.buildsets.getRecentBuildsets(2, branch='branch_a',
|
| + repository='bad_repo'))
|
| + def check(bsdictlist):
|
| + self.assertEqual(bsdictlist, [])
|
| + d.addCallback(check)
|
| + return d
|
|
|