Skip to content

Commit

Permalink
add unit test for issue #98
Browse files Browse the repository at this point in the history
  • Loading branch information
yathit committed Oct 27, 2016
1 parent 690fab7 commit 0bd007d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/crud/race_2_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,40 @@ function test_racy() {
to_del.push(to_del);
}

function test_issu98() {
var schema = {
stores: [
{
name: 'test',
keyPath: 'id',
indexes: [
{
keyPath: ['first', 'last']
},
{
keyPath: 'first'
},
{
keyPath: 'last'
}
]
}]};
var option = {mechanisms: ['websql']};
var db1 = new ydn.db.crud.Storage('issue98', schema, option);
asyncTestCase.waitForAsync('put in db1');
var data = {id: 1, first: 'First', last: 'Last'};
db1.put('test', data).addCallback(function() {
var db2 = new ydn.db.crud.Storage('issue98', schema, option);
asyncTestCase.continueTesting();
asyncTestCase.waitForAsync('values');
db1.close();
db2.values('test').addCallback(function(arr) {
assertArrayEquals(data, arr);
asyncTestCase.continueTesting();
ydn.db.deleteDatabase(db_name, db2.getType());
db2.close();
});
});
to_del.push(to_del);
}

0 comments on commit 0bd007d

Please sign in to comment.