-
-
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.
[SourceForge] Fixes, tests and cleaning up (#1626)
- Loading branch information
Showing
2 changed files
with
86 additions
and
33 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
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,54 @@ | ||
'use strict'; | ||
|
||
const Joi = require('joi'); | ||
const ServiceTester = require('../service-tester'); | ||
const { | ||
isMetric, | ||
isMetricOverTimePeriod | ||
} = require('../test-validators'); | ||
|
||
const t = new ServiceTester({ id: 'sourceforge', title: 'SourceForge' }); | ||
module.exports = t; | ||
|
||
t.create('total downloads') | ||
.get('/dt/sevenzip.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: 'downloads', | ||
value: isMetric, | ||
})); | ||
|
||
t.create('monthly downloads') | ||
.get('/dm/sevenzip.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: 'downloads', | ||
value: isMetricOverTimePeriod, | ||
})); | ||
|
||
t.create('weekly downloads') | ||
.get('/dw/sevenzip.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: 'downloads', | ||
value: isMetricOverTimePeriod, | ||
})); | ||
|
||
t.create('daily downloads') | ||
.get('/dd/sevenzip.json') | ||
.expectJSONTypes(Joi.object().keys({ | ||
name: 'downloads', | ||
value: isMetricOverTimePeriod, | ||
})); | ||
|
||
t.create('invalid project') | ||
.get('/dd/invalid.json') | ||
.expectJSON({ | ||
name: 'downloads', | ||
value: 'invalid', | ||
}); | ||
|
||
t.create('total downloads (connection error)') | ||
.get('/dt/sevenzip.json') | ||
.networkOff() | ||
.expectJSON({ | ||
name: 'downloads', | ||
value: 'inaccessible' | ||
}); |