Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Commit

Permalink
adds etag generation to mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-scherzinger committed Feb 23, 2016
1 parent 4416621 commit 96c914a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"browserify": "13.0.0",
"chai": "3.5.0",
"coveralls": "2.11.6",
"etag": "^1.7.0",
"express": "4.13.4",
"grunt": "0.4.5",
"grunt-browserify": "4.0.1",
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/mockserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var bodyParser = require('body-parser')
, fs = require('fs')
, path = require('path')
, walk = require('walk')
, etag = require('etag')
, _ = {};

_.isEqual = require('lodash.isequal');
Expand Down Expand Up @@ -64,7 +65,7 @@ app.all('/*', function(req, res, next) {
.split('https://datamanager.entrecode.de').join('http://localhost:54815/datamanager')
.split('https://appserver.entrecode.de').join('http://localhost:54815/appserver')
.split('https://accounts.entrecode.de').join('http://localhost:54815/accounts'));
res.status(fileStat.name.split('.')[1]).send(file.res);
res.status(fileStat.name.split('.')[1]).header('etag', etag(JSON.stringify(file.res))).send(file.res);
return nextFile();
});
});
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/setupMocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if (isNode) {
, walk = require('walk')
, path = require('path')
, fs = require('fs')
, etag = require('etag')
, _ = {}
;
_.isEmpty = require('lodash.isempty');
Expand Down Expand Up @@ -37,7 +38,7 @@ if (isNode) {
if (fileElems[1] === "500") {
dmMock = dmMock.replyWithError(file.res);
} else {
dmMock = dmMock.reply(fileElems[1], file.res);
dmMock = dmMock.reply(fileElems[1], file.res, { 'ETag': etag(JSON.stringify(file.res)) });
}

return next();
Expand Down

0 comments on commit 96c914a

Please sign in to comment.