* feat: started refactoring codecov * tests: removed erroneous test from draft PR * chore: prettified for prettier * feat: more codecov updates and tests * feat: more codecov refactor updates * feat: added codecov redirect content * refactor: removed legacy codecov service file * refactor(codecov): added redirect for legacy token route path * docs(codecov): added documentation to examples for token info * docs(codecov): updated vcs param in example patterns * refactor(codecov): update redirect service date Co-Authored-By: calebcartwright <calebcartwright@users.noreply.github.com> * refactor(codecov): various updates based on PR feedback * chore: added comment to codecov 401 test
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
'use strict'
|
|
|
|
const { isIntegerPercentage } = require('../test-validators')
|
|
const t = (module.exports = require('../tester').createServiceTester())
|
|
|
|
t.create('gets coverage status')
|
|
.get('/github/codecov/example-python.json')
|
|
.expectBadge({
|
|
label: 'coverage',
|
|
message: isIntegerPercentage,
|
|
})
|
|
|
|
t.create('gets coverage status for branch')
|
|
.get('/github/codecov/example-python/master.json')
|
|
.expectBadge({
|
|
label: 'coverage',
|
|
message: isIntegerPercentage,
|
|
})
|
|
|
|
t.create('handles unknown repository')
|
|
.get('/github/codecov2/fake-not-even-a-little-bit-real-python.json')
|
|
.expectBadge({
|
|
label: 'coverage',
|
|
message: 'repository not found',
|
|
})
|
|
|
|
// Using a mocked response here because we did not have a known
|
|
// private repository hooked up with Codecov that we could use.
|
|
t.create('handles unauthorized error')
|
|
.get('/github/codecov/private-example-python.json')
|
|
.intercept(nock =>
|
|
nock('https://codecov.io/api')
|
|
.get('/github/codecov/private-example-python')
|
|
.reply(401)
|
|
)
|
|
.expectBadge({
|
|
label: 'coverage',
|
|
message: 'not authorized to access repository',
|
|
})
|
|
|
|
t.create('gets coverage for private repository')
|
|
.get('/github/codecov/private-example-python.json?token=abc123def456')
|
|
.intercept(nock =>
|
|
nock('https://codecov.io/api', {
|
|
reqheaders: {
|
|
authorization: 'token abc123def456',
|
|
},
|
|
})
|
|
.get('/github/codecov/private-example-python')
|
|
.reply(200, {
|
|
commit: {
|
|
totals: {
|
|
c: 94.75,
|
|
},
|
|
},
|
|
})
|
|
)
|
|
.expectBadge({
|
|
label: 'coverage',
|
|
message: '95%',
|
|
})
|