Skip to content

Commit

Permalink
reporters/test_github: Add TestGitHubRegEX
Browse files Browse the repository at this point in the history
Adding test for testing the option base_re

Signed-off-by: Alice Ferrazzi <[email protected]>
  • Loading branch information
aliceinwire committed Sep 21, 2022
1 parent 6ddad8b commit 43fe504
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions master/buildbot/test/unit/reporters/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from buildbot.process.properties import Interpolate
from buildbot.process.results import FAILURE
from buildbot.process.results import SUCCESS
from buildbot.reporters.github import HOSTED_BASE_REGEX
from buildbot.reporters.github import HOSTED_BASE_URL
from buildbot.reporters.github import GitHubCommentPush
from buildbot.reporters.github import GitHubStatusPush
Expand Down Expand Up @@ -431,3 +432,71 @@ def test_multiple_source_stamps_no_props(self):
yield self.sp._got_event(('builds', 20, 'finished'), build)
build['results'] = SUCCESS
yield self.sp._got_event(('builds', 20, 'finished'), build)


# Testing HOSTED_BASE_REGEX
class TestGitHubRegEX(TestGitHubStatusPush):

def createService(self):
return GitHubStatusPush('XXYYZZ', base_re=HOSTED_BASE_REGEX)

@defer.inlineCallbacks
def test_source_stamps(self):
repository = 'http://test_repo'
project = 'test_user/test_project'
codebase1 = 'test_codebase1'
codebase2 = 'test_codebase2'
codebase3 = 'test_codebase3'
branch2 = 'refs/pull/4192/merge'
branch3 = 'refs/pull/4193/merge'

self._http.expect(
'post',
'/repos/test_user/test_project/issues/4192/comments',
json={'body': 'Build done.'})
self._http.expect(
'post',
'/repos/test_user/test_project/issues/4192/comments',
json={'body': 'Build done.'})
self._http.expect(
'post',
'/repos/test_user/test_project/issues/4192/comments',
json={'body': 'Build done.'})
self._http.expect(
'post',
'/repos/test_user/test_project/issues/4192/comments',
json={'body': 'Build done.'})

# note that the first sourcestamp only has revision, second only branch and only the third
# has both
self.master.db.insertTestData([
fakedb.Master(id=92),
fakedb.Worker(id=13, name='wrk'),
fakedb.Builder(id=79, name='Builder0'),
fakedb.Buildset(id=98, results=SUCCESS, reason="test_reason1"),
fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=235),
fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=236),
fakedb.SourceStamp(id=234, project=project, branch=None, revision='rev1',
repository=repository, codebase=codebase1),
fakedb.SourceStamp(id=235, project=project, branch=branch2, revision=None,
repository=repository, codebase=codebase2),
fakedb.SourceStamp(id=236, project=project, branch=branch3, revision='rev3',
repository=repository, codebase=codebase3),
fakedb.BuildRequest(id=11, buildsetid=98, builderid=79),
fakedb.Build(id=20, number=0, builderid=79, buildrequestid=11,
workerid=13, masterid=92, results=SUCCESS, state_string="build_text"),
fakedb.BuildProperty(buildid=20, name="buildername", value="Builder0"),
fakedb.BuildProperty(buildid=20, name="branch", value=branch2),
])

self.setup_fake_get_changes_for_build(has_change=False)

build = yield self.master.data.get(("builds", 20))

build['complete'] = False
yield self.sp._got_event(('builds', 20, 'new'), build)
build['complete'] = True
yield self.sp._got_event(('builds', 20, 'finished'), build)
build['results'] = SUCCESS
yield self.sp._got_event(('builds', 20, 'finished'), build)

0 comments on commit 43fe504

Please sign in to comment.