-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update github contributors badge for `create-service-tester`.
- Loading branch information
1 parent
382af10
commit 4e5e3c8
Showing
21 changed files
with
989 additions
and
898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const { isMetricOverTimePeriod } = require('../test-validators') | ||
|
||
const t = (module.exports = require('../create-service-tester')()) | ||
|
||
t.create('commit activity (1 year)') | ||
.get('/y/eslint/eslint.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'commit activity', | ||
value: isMetricOverTimePeriod, | ||
}) | ||
) | ||
|
||
t.create('commit activity (4 weeks)') | ||
.get('/4w/eslint/eslint.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'commit activity', | ||
value: isMetricOverTimePeriod, | ||
}) | ||
) | ||
|
||
t.create('commit activity (1 week)') | ||
.get('/w/eslint/eslint.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'commit activity', | ||
value: isMetricOverTimePeriod, | ||
}) | ||
) | ||
|
||
t.create('commit activity (repo not found)') | ||
.get('/w/badges/helmets.json') | ||
.expectJSON({ | ||
name: 'commit activity', | ||
value: 'repo not found', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
'use strict' | ||
|
||
const { colorScheme: colorsB } = require('../test-helpers') | ||
const { invalidJSON } = require('../response-fixtures') | ||
|
||
const t = (module.exports = require('../create-service-tester')()) | ||
|
||
t.create('commit status - commit in branch') | ||
.get( | ||
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test' | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'in master', | ||
colorB: colorsB.brightgreen, | ||
}) | ||
|
||
t.create( | ||
'commit status - checked commit is identical with the newest commit in branch' | ||
) | ||
.get( | ||
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test' | ||
) | ||
.intercept(nock => | ||
nock('https://api.github.com') | ||
.get( | ||
'/repos/badges/shields/compare/master...5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c' | ||
) | ||
.reply(200, { status: 'identical' }) | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'in master', | ||
colorB: colorsB.brightgreen, | ||
}) | ||
|
||
t.create('commit status - commit not in branch') | ||
.get( | ||
'/badges/shields/master/960c5bf72d7d1539fcd453343eed3f8617427a41.json?style=_shields_test' | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'commit or branch not found', | ||
colorB: colorsB.lightgrey, | ||
}) | ||
|
||
t.create('commit status - unknown commit id') | ||
.get( | ||
'/atom/atom/v1.27.1/7dfb45eb61a48a4ce18a0dd2e31f944ed4467ae3.json?style=_shields_test' | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'not in v1.27.1', | ||
colorB: colorsB.yellow, | ||
}) | ||
|
||
t.create('commit status - unknown branch') | ||
.get( | ||
'/badges/shields/this-branch-does-not-exist/b551a3a8daf1c48dba32a3eab1edf99b10c28863.json?style=_shields_test' | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'commit or branch not found', | ||
colorB: colorsB.lightgrey, | ||
}) | ||
|
||
t.create('commit status - no common ancestor between commit and branch') | ||
.get( | ||
'/badges/shields/master/b551a3a8daf1c48dba32a3eab1edf99b10c28863.json?style=_shields_test' | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'no common ancestor', | ||
colorB: colorsB.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) | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'invalid', | ||
colorB: colorsB.lightgrey, | ||
}) | ||
|
||
t.create('commit status - network error') | ||
.get( | ||
'/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.json?style=_shields_test' | ||
) | ||
.networkOff() | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'inaccessible', | ||
colorB: colorsB.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) | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'invalid', | ||
colorB: colorsB.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, {}) | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'invalid', | ||
colorB: colorsB.lightgrey, | ||
}) | ||
|
||
t.create('commit status - 404 with invalid 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, invalidJSON) | ||
) | ||
.expectJSON({ | ||
name: 'commit status', | ||
value: 'invalid', | ||
colorB: colorsB.lightgrey, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
|
||
const t = (module.exports = require('../create-service-tester')()) | ||
|
||
t.create('Commits since') | ||
.get('/badges/shields/a0663d8da53fb712472c02665e6ff7547ba945b7.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: Joi.string().regex(/^(commits since){1}[\s\S]+$/), | ||
value: Joi.string().regex(/^\w+$/), | ||
}) | ||
) | ||
|
||
t.create('Commits since by latest release') | ||
.get('/microsoft/typescript/latest.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: Joi.string().regex(/^(commits since){1}[\s\S]+$/), | ||
value: Joi.string().regex(/^\d+\w?$/), | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
|
||
const t = (module.exports = require('../create-service-tester')()) | ||
|
||
t.create('Contributors') | ||
.get('/cdnjs/cdnjs.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'contributors', | ||
value: Joi.string().regex(/^\w+$/), | ||
}) | ||
) | ||
|
||
t.create('Contributors (repo not found)') | ||
.get('/badges/helmets.json') | ||
.expectJSON({ | ||
name: 'contributors', | ||
value: 'repo not found', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const { isMetric } = require('../test-validators') | ||
|
||
const t = (module.exports = require('../create-service-tester')()) | ||
|
||
t.create('Downloads all releases') | ||
.get('/downloads/photonstorm/phaser/total.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex(/^\w+\s+total$/), | ||
}) | ||
) | ||
|
||
t.create('Downloads all releases (repo not found)') | ||
.get('/downloads/badges/helmets/total.json') | ||
.expectJSON({ | ||
name: 'downloads', | ||
value: 'repo or release not found', | ||
}) | ||
|
||
t.create('downloads for latest release') | ||
.get('/downloads/photonstorm/phaser/latest/total.json') | ||
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric })) | ||
|
||
t.create('downloads-pre for latest release') | ||
.get('/downloads-pre/photonstorm/phaser/latest/total.json') | ||
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric })) | ||
|
||
t.create('downloads for release without slash') | ||
.get('/downloads/atom/atom/v0.190.0/total.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? v0\.190\.0$/), | ||
}) | ||
) | ||
|
||
t.create('downloads for specific asset without slash') | ||
.get('/downloads/atom/atom/v0.190.0/atom-amd64.deb.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex( | ||
/^[0-9]+[kMGTPEZY]? v0\.190\.0 \[atom-amd64\.deb\]$/ | ||
), | ||
}) | ||
) | ||
|
||
t.create('downloads for specific asset from latest release') | ||
.get('/downloads/atom/atom/latest/atom-amd64.deb.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? \[atom-amd64\.deb\]$/), | ||
}) | ||
) | ||
|
||
t.create('downloads-pre for specific asset from latest release') | ||
.get('/downloads-pre/atom/atom/latest/atom-amd64.deb.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? \[atom-amd64\.deb\]$/), | ||
}) | ||
) | ||
|
||
t.create('downloads for release with slash') | ||
.get('/downloads/NHellFire/dban/stable/v2.2.8/total.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex(/^[0-9]+[kMGTPEZY]? stable\/v2\.2\.8$/), | ||
}) | ||
) | ||
|
||
t.create('downloads for specific asset with slash') | ||
.get('/downloads/NHellFire/dban/stable/v2.2.8/dban-2.2.8_i586.iso.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'downloads', | ||
value: Joi.string().regex( | ||
/^[0-9]+[kMGTPEZY]? stable\/v2\.2\.8 \[dban-2\.2\.8_i586\.iso\]$/ | ||
), | ||
}) | ||
) | ||
|
||
t.create('downloads for unknown release') | ||
.get('/downloads/atom/atom/does-not-exist/total.json') | ||
.expectJSON({ name: 'downloads', value: 'repo or release not found' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
|
||
const t = (module.exports = require('../create-service-tester')()) | ||
|
||
t.create('Followers') | ||
.get('/webcaetano.json') | ||
.expectJSONTypes( | ||
Joi.object().keys({ | ||
name: 'followers', | ||
value: Joi.string().regex(/^\w+$/), | ||
}) | ||
) | ||
|
||
t.create('Followers (user not found)') | ||
.get('/PyvesB2.json') | ||
.expectJSON({ | ||
name: 'followers', | ||
value: 'user not found', | ||
}) |
Oops, something went wrong.