From 2aeed7e2a9a2171026e198ae221e75ea4a3316c8 Mon Sep 17 00:00:00 2001 From: Simone Vittori Date: Sat, 12 Aug 2017 18:51:02 +0100 Subject: [PATCH] Add tests for hex.pm integration --- service-tests/hexpm.js | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 service-tests/hexpm.js diff --git a/service-tests/hexpm.js b/service-tests/hexpm.js new file mode 100644 index 0000000000..ea390d7b7f --- /dev/null +++ b/service-tests/hexpm.js @@ -0,0 +1,51 @@ +'use strict'; + +const Joi = require('joi'); +const ServiceTester = require('./runner/service-tester'); + +const t = new ServiceTester({ id: 'hexpm', title: 'Hex.pm' }); +module.exports = t; + +t.create('downloads per week') + .get('/dw/cowboy.json') + .expectJSONTypes(Joi.object().keys({ + name: Joi.equal('downloads'), + value: Joi.string().regex(/^\d+[a-z]?\/week$/) + })); + +t.create('downloads per day') + .get('/dd/cowboy.json') + .expectJSONTypes(Joi.object().keys({ + name: Joi.equal('downloads'), + value: Joi.string().regex(/^\d+[a-z]?\/day$/) + })); + +t.create('downloads in total') + .get('/dt/cowboy.json') + .expectJSONTypes(Joi.object().keys({ + name: Joi.equal('downloads'), + value: Joi.string().regex(/^\d+[kMGTPEZY]?$/) + })); + +t.create('version') + .get('/v/cowboy.json') + .expectJSONTypes(Joi.object().keys({ + name: Joi.equal('hex'), + value: Joi.string().regex(/^v\d+.\d+.?\d?$/) + })); + +t.create('license') + .get('/l/cowboy.json') + .expectJSONTypes(Joi.object().keys({ + name: Joi.equal('license'), + value: Joi.string().required() + })); + +t.create('unknown repo') + .get('/l/this-repo-does-not-exist.json') + .expectJSON({ name: 'hex', value: 'invalid' }); + +t.create('connection error') + .get('/l/cowboy.json') + .networkOff() + .expectJSON({ name: 'hex', value: 'inaccessible' });