Rewrite GitHub commit status (#3186)

* WIP

* Parse the error response

* Clarify

* Restore one test

* Add a schema
This commit is contained in:
Paul Melnikow
2019-03-10 19:43:37 -04:00
committed by Caleb Cartwright
parent cbcf980182
commit 3733de6232
5 changed files with 96 additions and 149 deletions

View File

@@ -39,7 +39,7 @@ t.create('commit status - commit not in branch')
.expectBadge({
label: 'commit status',
message: 'commit or branch not found',
color: 'lightgrey',
color: 'red',
})
t.create('commit status - unknown commit id')
@@ -59,7 +59,7 @@ t.create('commit status - unknown branch')
.expectBadge({
label: 'commit status',
message: 'commit or branch not found',
color: 'lightgrey',
color: 'red',
})
t.create('commit status - no common ancestor between commit and branch')
@@ -69,71 +69,11 @@ t.create('commit status - no common ancestor between commit and branch')
.expectBadge({
label: 'commit status',
message: 'no common ancestor',
color: 'lightgrey',
})
t.create('commit status - invalid JSON')
.get(
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
)
.intercept(nock =>
nock('https://api.github.com')
.get(
'/repos/badges/shields/compare/master...5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c'
)
.reply(invalidJSON)
)
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})
t.create('commit status - network error')
.get(
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
)
.networkOff()
.expectBadge({
label: 'commit status',
message: 'inaccessible',
color: 'red',
})
t.create('commit status - github server error')
.get(
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
)
.intercept(nock =>
nock('https://api.github.com')
.get(
'/repos/badges/shields/compare/master...5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c'
)
.reply(500)
)
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})
t.create('commit status - 404 with empty JSON form github')
.get(
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
)
.intercept(nock =>
nock('https://api.github.com')
.get(
'/repos/badges/shields/compare/master...5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c'
)
.reply(404, {})
)
.expectBadge({
label: 'commit status',
message: 'invalid',
color: 'lightgrey',
})
// Since the service is responsible for parsing its error response, this tests
// the service, not BaseJsonService.
t.create('commit status - 404 with invalid JSON form github')
.get(
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test'
@@ -147,6 +87,6 @@ t.create('commit status - 404 with invalid JSON form github')
)
.expectBadge({
label: 'commit status',
message: 'invalid',
message: 'unparseable json response',
color: 'lightgrey',
})