Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions test/processor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,62 @@ describe('DynamoProcessor', () => {
});
});

context('concurrent update with initFields', () => {
it('updates an item avoiding conflicts', () => {
const initFields = {
str: null, map1: {}, map2: {}, map3: {}
};

return helper.putDoc({
id: 6,
str: 'something'
})
.then(data => {
return Promise.all([
dp.proc({
table: 'tests',
key: { id: 6 },
set: {
'map1 left': true
}
}, { initFields }),
dp.proc({
table: 'tests',
key: { id: 6 },
set: {
'map2 right': 'string'
}
}, { initFields }),
dp.proc({
table: 'tests',
key: { id: 6 },
set: {
'map3 center': 123
}
}, { initFields })
])
})
.then(results => {
return helper.getDoc(6);
})
.then(item => {
expect(item).to.deep.equal({
id: 6,
str: 'something',
map1: {
left: true
},
map2: {
right: 'string'
},
map3: {
center: 123
}
});
});
});
});

context('multiple items', () => {
const data1 = { id: 10, name: 'Karen' };
const data2 = { id: 11, name: 'Hana' };
Expand Down