-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test for issue #98 with clean up.
- Loading branch information
Showing
3 changed files
with
91 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test for Race condition</title> | ||
</head> | ||
<body> | ||
|
||
<script src="../../../closure-library/closure/goog/base.js"></script> | ||
<script src="../../../closure-library/closure/goog/deps.js"></script> | ||
<script type="text/javascript" src="../../../ydn-base/src/deps.js"></script> | ||
<script type="text/javascript" src="../../src/deps.js"></script> | ||
<script type="text/javascript" > | ||
goog.require('ydn.debug'); | ||
goog.require('goog.userAgent'); | ||
goog.require('goog.testing.AsyncTestCase'); | ||
goog.require('goog.testing.jsunit'); | ||
goog.require('ydn.db.crud.Storage'); | ||
</script> | ||
<script type="text/javascript" src="../../src/ydn/db/tr/inject.js"></script> | ||
<script type="text/javascript" src="../../src/ydn/db/crud/inject.js"></script> | ||
<script type="text/javascript" src="issue_98_test.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
|
||
goog.require('goog.debug.Console'); | ||
goog.require('goog.testing.AsyncTestCase'); | ||
goog.require('goog.testing.jsunit'); | ||
goog.require('ydn.async'); | ||
goog.require('ydn.db.crud.Storage'); | ||
goog.require('ydn.debug'); | ||
|
||
var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall(); | ||
var to_del = []; | ||
|
||
|
||
var setUp = function() { | ||
ydn.json.POLY_FILL = true; | ||
}; | ||
|
||
var tearDown = function() { | ||
|
||
}; | ||
|
||
function composite_index_test(type) { | ||
var db_name = 'issue98'; | ||
var schema = { | ||
stores: [ | ||
{ | ||
name: 'test', | ||
keyPath: 'id', | ||
indexes: [ | ||
{ | ||
keyPath: ['first', 'last'] | ||
}, | ||
{ | ||
keyPath: 'first' | ||
}, | ||
{ | ||
keyPath: 'last' | ||
} | ||
] | ||
}]}; | ||
var option = {mechanisms: [type]}; | ||
var db1 = new ydn.db.crud.Storage(db_name, 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(db_name, schema, option); | ||
asyncTestCase.continueTesting(); | ||
asyncTestCase.waitForAsync('values'); | ||
db1.close(); | ||
db2.values('test').addCallback(function(arr) { | ||
assertObjectEquals(data, arr[0]); | ||
asyncTestCase.continueTesting(); | ||
ydn.db.deleteDatabase(db_name, db2.getType()); | ||
db2.close(); | ||
}); | ||
}); | ||
to_del.push(db_name); | ||
} | ||
|
||
function test_composite_index_idb() { | ||
composite_index_test('indexeddb'); | ||
} | ||
|
||
function test_composite_index_websql() { | ||
composite_index_test('websql'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters