Skip to content

Commit 5b6af25

Browse files
committed
Fixing cache test and adding proxy test
1 parent c55fded commit 5b6af25

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

test/integration/proxy.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ describe('Proxy', function () {
4343
{ method: 'POST', path: '/item', config: { proxy: { host: '127.0.0.1', port: 18093 } } },
4444
{ method: 'POST', path: '/notfound', config: { proxy: { host: '127.0.0.1', port: 18093 } } },
4545
{ method: 'GET', path: '/postResponseError', config: { proxy: { host: '127.0.0.1', port: 18093, postResponse: postResponseWithError }, cache: routeCache } },
46-
{ method: 'POST', path: '/echo', config: { proxy: { mapUri: mapUri } } }
46+
{ method: 'POST', path: '/echo', config: { proxy: { mapUri: mapUri } } },
47+
{ method: 'GET', path: '/maperror', config: { proxy: { mapUri: mapUriWithError } } }
4748
]);
4849

4950
dummyServer.listener.on('listening', function () {
@@ -72,6 +73,11 @@ describe('Proxy', function () {
7273
return callback(null, 'http://127.0.0.1:18093' + request.path, request.query);
7374
}
7475

76+
function mapUriWithError(request, callback) {
77+
78+
return callback(new Error('myerror'));
79+
}
80+
7581
function profile(request) {
7682

7783
request.reply({
@@ -209,4 +215,13 @@ describe('Proxy', function () {
209215
done();
210216
});
211217
});
218+
219+
it('replies with an error when it occurs in mapUri', function(done) {
220+
221+
makeRequest({ path: '/maperror', method: 'get' }, function (rawRes) {
222+
223+
expect(rawRes.body).to.contain('myerror');
224+
done();
225+
});
226+
});
212227
});

test/unit/cache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ require('../suite')(function (useRedis, useMongo) {
785785
it('returns a positive number when using a future expiresAt', function (done) {
786786

787787
var hour = new Date(Date.now() + 60 * 60 * 1000).getHours();
788+
hour = hour === 0 ? 1 : hour;
788789

789790
var config = {
790791
expiresAt: hour + ':00'

0 commit comments

Comments
 (0)