forked from badges/shields
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcran.js
More file actions
46 lines (37 loc) · 1.28 KB
/
cran.js
File metadata and controls
46 lines (37 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
const Joi = require('joi');
const ServiceTester = require('./runner/service-tester');
const t = new ServiceTester({ id: 'cran', title: 'CRAN/METACRAN' });
module.exports = t;
t.create('version')
.get('/v/devtools.json')
.expectJSONTypes(Joi.object().keys({
name: Joi.equal('cran'),
value: Joi.string().regex(/^v\d+\.\d+\.\d+$/)
}));
t.create('specified license')
.get('/l/devtools.json')
.expectJSON({ name: 'license', value: 'GPL (>= 2)' });
t.create('unknown package')
.get('/l/some-bogus-package.json')
.expectJSON({ name: 'cran', value: 'not found' });
t.create('unknown info')
.get('/z/devtools.json')
.expectStatus(404)
.expectJSON({ name: '404', value: 'badge not found' });
t.create('malformed response')
.get('/v/foobar.json')
.intercept(nock => nock('http://crandb.r-pkg.org')
.get('/foobar')
.reply(200)) // JSON without Version.
.expectJSON({ name: 'cran', value: 'invalid' });
t.create('connection error')
.get('/v/foobar.json')
.networkOff()
.expectJSON({ name: 'cran', value: 'inaccessible' });
t.create('unspecified license')
.get('/l/foobar.json')
.intercept(nock => nock('http://crandb.r-pkg.org')
.get('/foobar')
.reply(200, {})) // JSON without License.
.expectJSON({ name: 'license', value: 'unknown' });