Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
Signed-off-by: Alice Ferrazzi <[email protected]>
  • Loading branch information
aliceinwire committed Sep 20, 2022
1 parent b09a1cd commit b245a6f
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 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,98 @@ 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(TestReactorMixin, unittest.TestCase,
ReporterTestMixin):

@defer.inlineCallbacks
def setUp(self):
self.setup_test_reactor()

self.setup_reporter_test()
# project must be in the form <owner>/<project>
self.reporter_test_project = 'buildbot'
self.reporter_test_repo = 'https://github.com/buildbot1/buildbot1.git'

self.master = fakemaster.make_master(self, wantData=True, wantDb=True,
wantMq=True)

yield self.master.startService()
self._http = yield fakehttpclientservice.HTTPClientService.getService(
self.master, self,
HOSTED_BASE_URL, headers={
'Authorization': 'token XXYYZZ',
'User-Agent': 'Buildbot'
},
debug=None, verify=None)
self.sp = self.createService()
yield self.sp.setServiceParent(self.master)

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

def tearDown(self):
return self.master.stopService()

@defer.inlineCallbacks
def test_ssh(self):
self.reporter_test_repo = '[email protected]:buildbot2/buildbot2.git'

build = yield self.insert_build_new()
# we make sure proper calls to txrequests have been made
self._http.expect(
'post',
'/repos/buildbot2/buildbot2/statuses/d34db33fd43db33f',
json={'state': 'pending',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build started.', 'context': 'buildbot/Builder0'})
self._http.expect(
'post',
'/repos/buildbot2/buildbot2/statuses/d34db33fd43db33f',
json={'state': 'success',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build done.', 'context': 'buildbot/Builder0'})
self._http.expect(
'post',
'/repos/buildbot2/buildbot2/statuses/d34db33fd43db33f',
json={'state': 'failure',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build done.', 'context': 'buildbot/Builder0'})

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

@defer.inlineCallbacks
def test_https(self):
build = yield self.insert_build_new()
# we make sure proper calls to txrequests have been made
self._http.expect(
'post',
'/repos/buildbot1/buildbot1/statuses/d34db33fd43db33f',
json={'state': 'pending',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build started.', 'context': 'buildbot/Builder0'})
self._http.expect(
'post',
'/repos/buildbot1/buildbot1/statuses/d34db33fd43db33f',
json={'state': 'success',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build done.', 'context': 'buildbot/Builder0'})
self._http.expect(
'post',
'/repos/buildbot1/buildbot1/statuses/d34db33fd43db33f',
json={'state': 'failure',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build done.', 'context': 'buildbot/Builder0'})

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

0 comments on commit b245a6f

Please sign in to comment.