Use a set to compare surrogate keys, avoiding key order errors

This commit is contained in:
Raul Ochoa 2016-02-17 12:15:20 +01:00
parent 6ece30fa2c
commit 3d0c0f34ad

View File

@ -63,7 +63,15 @@ function checkCache(res) {
function checkSurrogateKey(res, expectedKey) {
assert.ok(res.headers.hasOwnProperty('surrogate-key'));
assert.equal(res.headers['surrogate-key'], expectedKey);
function createSet(keys, key) {
keys[key] = true;
return keys;
}
var keys = res.headers['surrogate-key'].split(' ').reduce(createSet, {});
var expectedKeys = expectedKey.split(' ').reduce(createSet, {});
assert.deepEqual(keys, expectedKeys);
}
//global afterEach to capture test suites that leave keys in redis