Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tmacro committed Aug 15, 2023
1 parent e140b63 commit 03989ec
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/unit/versioning/VersioningRequestProcessor.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('assert');
const async = require('async');
const { getInfVid } = require('../../../lib/versioning/VersionID');

const Version = require('../../../lib/versioning/Version').Version;

Expand Down Expand Up @@ -219,4 +220,56 @@ describe('test VSP', () => {
}],
done);
});

it('should update master if a infinite versionId is passed and the master does not have a versionId', done => {
let v1;
let v2;

async.waterfall([next => {
const request = {
db: 'foo',
key: 'bar',
value: '{"qux":"quz"}',
options: { versioning: false },
};
vsp.put(request, logger, next);
},
(res, next) => {
// should overwrite the master
const request = {
db: 'foo',
key: 'bar',
value: '{"qux":"quz2"}',
options: { versioning: true, versionId: getInfVid('PARIS') },
};
vsp.put(request, logger, next);
},
(_, next) => {
// fetch master
const request = {
db: 'foo',
key: 'bar',
};
vsp.get(request, logger, next);
},
(res, next) => {
// check that master has been updated
assert.strictEqual(JSON.parse(res).qux, 'quz2');
next();
},
(next) => {
// check that the version is accessible
const request = {
db: 'foo',
key: 'bar',
versionId: getInfVid('PARIS'),
};
vsp.get(request, logger, next);
},
(res, next) => {
assert.strictEqual(JSON.parse(res).qux, 'quz2');
next();
}],
done);
});
});

0 comments on commit 03989ec

Please sign in to comment.