Updated senderror unittest and removed invalid array access.

This commit is contained in:
Marvin Pohl 2019-03-09 16:48:41 +01:00
parent babf10f923
commit 7b04082c7c
2 changed files with 7 additions and 4 deletions

View File

@ -152,7 +152,7 @@ class GiteaStatusPush(http.HttpStatusPushBase):
)
if res.code not in (200, 201, 204):
message = yield res.json()
message = message[0].get('message', 'unspecified error')
message = message.get('message', 'unspecified error')
log.msg(
'Could not send status "{state}" for '
'{repo} at {sha}: {code} : {message}'.format(

View File

@ -154,14 +154,17 @@ class TestGiteaStatusPush(
json={'state': 'pending',
'target_url': 'http://localhost:8080/#builders/79/builds/0',
'description': 'Build started.', 'context': 'buildbot/Builder0'},
content_json={'message': 'sha1 not found for branch master'},
code=404)
content_json={
"message": "sha1 not found: d34db33fd43db33f",
"url": "https://godoc.org/github.com/go-gitea/go-sdk/gitea"
},
code=500)
build['complete'] = False
self.sp.buildStarted(("build", 20, "started"), build)
self.assertLogged(
"Could not send status \"pending\" for "
"http://gitea/buildbot/buildbot at d34db33fd43db33f:"
" sha1 not found for branch master")
" 500 : sha1 not found: d34db33fd43db33f")
@defer.inlineCallbacks
def test_badchange(self):