From 96c914a079fbcc7da7284a4ce6da2ac495d9ea97 Mon Sep 17 00:00:00 2001 From: Simon Scherzinger Date: Tue, 23 Feb 2016 17:03:46 +0100 Subject: [PATCH] adds etag generation to mocks --- package.json | 1 + test/mocks/mockserver.js | 3 ++- test/mocks/setupMocks.test.js | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6685224..d95cde7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/mocks/mockserver.js b/test/mocks/mockserver.js index 345adca..f5f51f7 100644 --- a/test/mocks/mockserver.js +++ b/test/mocks/mockserver.js @@ -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'); @@ -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(); }); }); diff --git a/test/mocks/setupMocks.test.js b/test/mocks/setupMocks.test.js index 5810fc6..2e78541 100644 --- a/test/mocks/setupMocks.test.js +++ b/test/mocks/setupMocks.test.js @@ -7,6 +7,7 @@ if (isNode) { , walk = require('walk') , path = require('path') , fs = require('fs') + , etag = require('etag') , _ = {} ; _.isEmpty = require('lodash.isempty'); @@ -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();