Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis service tests from tutorial #1531

Merged
merged 4 commits into from
Mar 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ cache(function(data, match, sendBadge, request) {
if (err != null) {
log.error('Travis error: ' + err.stack);
if (res) { log.error(''+res); }
badgeData.text[1] = 'invalid';
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions service-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cache(function(data, match, sendBadge, request) {
if (err != null) {
console.error('Travis error: ' + err.stack); // 5
if (res) { console.error(''+res); }
badgeData.text[1] = 'invalid';
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ network connection errors on any unmocked requests.
t.create('connection error')
.get('/foo/bar.json')
.networkOff()
.expectJSON({ name: 'build', value: 'invalid' });
.expectJSON({ name: 'build', value: 'inaccessible' });
```


Expand Down Expand Up @@ -338,7 +338,7 @@ t.create('missing content-disposition header')
t.create('connection error')
.get('/foo/bar.json')
.networkOff()
.expectJSON({ name: 'build', value: 'invalid' });
.expectJSON({ name: 'build', value: 'inaccessible' });
```


Expand Down
36 changes: 35 additions & 1 deletion service-tests/travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,43 @@ const Joi = require('joi');
const ServiceTester = require('./runner/service-tester');
const {isPhpVersionReduction} = require('./helpers/validators');

const t = new ServiceTester({ id: 'travis', title: 'PHP version from .travis.yml' });
const t = new ServiceTester({ id: 'travis', title: 'Travis CI/PHP version from .travis.yml' });
module.exports = t;

// Travis CI

t.create('build status on default branch')
.get('/rust-lang/rust.json')
.expectJSONTypes(Joi.object().keys({
name: 'build',
value: Joi.equal('failing', 'passing', 'unknown')
}));

t.create('build status on named branch')
.get('/rust-lang/rust/stable.json')
.expectJSONTypes(Joi.object().keys({
name: 'build',
value: Joi.equal('failing', 'passing', 'unknown')
}));

t.create('unknown repo')
.get('/this-repo/does-not-exist.json')
.expectJSON({ name: 'build', value: 'unknown' });

t.create('missing content-disposition header')
.get('/foo/bar.json')
.intercept(nock => nock('https://api.travis-ci.org')
.head('/foo/bar.svg')
.reply(200))
.expectJSON({ name: 'build', value: 'invalid' });

t.create('connection error')
.get('/foo/bar.json')
.networkOff()
.expectJSON({ name: 'build', value: 'inaccessible' });

// PHP version from .travis.yml

t.create('gets the package version of symfony')
.get('/php-v/symfony/symfony.json')
.expectJSONTypes(Joi.object().keys({ name: 'PHP', value: isPhpVersionReduction }));
Expand Down