-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from wikimedia/phab/T88652-2
Revisions
- Loading branch information
Showing
9 changed files
with
285 additions
and
107 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
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
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
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,68 @@ | ||
'use strict'; | ||
|
||
// mocha defines to avoid JSHint breakage | ||
/* global describe, it, before, beforeEach, after, afterEach */ | ||
|
||
var assert = require('../../utils/assert.js'); | ||
var preq = require('preq'); | ||
var server = require('../../utils/server.js'); | ||
|
||
|
||
describe('revision requests', function() { | ||
|
||
this.timeout(20000); | ||
|
||
before(function () { return server.start(); }); | ||
|
||
it('should return valid revision info', function() { | ||
return preq.get({ uri: server.config.bucketURL + '/revision/642497713' }) | ||
.then(function(res) { | ||
assert.deepEqual(res.status, 200); | ||
assert.deepEqual(res.body.items.length, 1); | ||
assert.deepEqual(res.body.items[0].rev, 642497713); | ||
assert.deepEqual(res.body.items[0].title, 'Foobar'); | ||
}); | ||
}); | ||
|
||
it('should query the MW API for revision info', function() { | ||
var slice = server.config.logStream.slice(); | ||
return preq.get({ | ||
uri: server.config.bucketURL + '/revision/642497713', | ||
headers: { 'cache-control': 'no-cache' } | ||
}) | ||
.then(function(res) { | ||
slice.halt(); | ||
assert.deepEqual(res.status, 200); | ||
assert.deepEqual(res.body.items.length, 1); | ||
assert.deepEqual(res.body.items[0].rev, 642497713); | ||
assert.deepEqual(res.body.items[0].title, 'Foobar'); | ||
assert.remoteRequests(slice, true); | ||
}); | ||
}); | ||
|
||
it('should fail for an invalid revision', function() { | ||
return preq.get({ uri: server.config.bucketURL + '/revision/faultyrevid' }) | ||
.then(function(res) { | ||
throw new Error('Expected status 400 for an invalid revision, got ' + res.status); | ||
}, | ||
function(res) { | ||
assert.deepEqual(res.status, 400); | ||
}); | ||
}); | ||
|
||
it('should query the MW API for a non-existent revision and return a 404', function() { | ||
var slice = server.config.logStream.slice(); | ||
return preq.get({ uri: server.config.bucketURL + '/revision/0' }) | ||
.then(function(res) { | ||
slice.halt(); | ||
throw new Error('Expected status 404 for an invalid revision, got ' + res.status); | ||
}, | ||
function(res) { | ||
slice.halt(); | ||
assert.deepEqual(res.status, 404); | ||
assert.remoteRequests(slice, true); | ||
}); | ||
}); | ||
|
||
}); | ||
|
Oops, something went wrong.