mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-10 23:55:08 +00:00
update db concurrent test
This commit is contained in:
parent
486d2006c0
commit
001469509f
@ -24,28 +24,40 @@ describe('Db concurrency', function() {
|
||||
|
||||
describe('prallel builds put should produce different ids', function() {
|
||||
|
||||
var firstBuild = makeBuild({project: {name: 'project1'}}),
|
||||
secondBuild = makeBuild({project: {name: 'project2'}});
|
||||
var expectedIds = [];
|
||||
var builds = _(2).chain().range().map(function(number) {
|
||||
expectedIds.push(number + 1);
|
||||
return makeBuild({project: {name: 'project' + number}});
|
||||
}).value();
|
||||
|
||||
it('put two builds in parallel without errors', function(done) {
|
||||
Steppy(
|
||||
function() {
|
||||
db.builds.put(firstBuild, this.slot());
|
||||
db.builds.put(secondBuild, this.slot());
|
||||
var putGroup = this.makeGroup();
|
||||
_(builds).each(function(build) {
|
||||
db.builds.put(build, putGroup.slot());
|
||||
});
|
||||
},
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('shoud have ids 1, 2', function() {
|
||||
expect(_([firstBuild.id, secondBuild.id]).sortBy()).eql([1, 2]);
|
||||
it('shoud have ids ' + expectedIds.join(', '), function() {
|
||||
expect(_(builds).chain().pluck('id').sortBy().value()).eql(
|
||||
expectedIds
|
||||
);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
db.builds.del(expectedIds, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('prallel builds put should produce different numbers', function() {
|
||||
|
||||
var builds = _(3).chain().range().map(function() {
|
||||
var expectedIds = [];
|
||||
var builds = _(3).chain().range().map(function(number) {
|
||||
expectedIds.push(number + 1);
|
||||
return makeBuild({
|
||||
project: {name: 'project1'},
|
||||
status: 'in-progress'
|
||||
@ -55,20 +67,23 @@ describe('Db concurrency', function() {
|
||||
it('put three builds in parallel without errors', function(done) {
|
||||
Steppy(
|
||||
function() {
|
||||
var step = this;
|
||||
var putGroup = this.makeGroup();
|
||||
_(builds).each(function(build) {
|
||||
db.builds.put(build, step.slot());
|
||||
db.builds.put(build, putGroup.slot());
|
||||
});
|
||||
},
|
||||
done
|
||||
);
|
||||
});
|
||||
|
||||
it('shoud have ids 3, 4, 5', function() {
|
||||
it('shoud have ids ' + expectedIds.join(', '), function() {
|
||||
expect(_(builds).chain().pluck('id').sortBy().value()).eql(
|
||||
[3, 4, 5]
|
||||
expectedIds
|
||||
);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
db.builds.del(expectedIds, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user