未验证 提交 caaf5743 编写于 作者: O openharmony_ci 提交者: Gitee

!6678 【Distributeddatamgr】【master】用例执行时效优化

Merge pull request !6678 from 梁梁/master
...@@ -134,7 +134,7 @@ export default function rdbStoreBackupRestoreCallbackTest() { ...@@ -134,7 +134,7 @@ export default function rdbStoreBackupRestoreCallbackTest() {
console.info(TAG + "************* RdbBackupRestoreCallbackTest_0100 start *************") console.info(TAG + "************* RdbBackupRestoreCallbackTest_0100 start *************")
// RDB backup function test // RDB backup function test
await RdbStore.backup(DATABASE_BACKUP_NAME, (err, data) => { await RdbStore.backup(DATABASE_BACKUP_NAME,async (err, data) => {
if(err != null){ if(err != null){
expect(false).assertTrue() expect(false).assertTrue()
}else{ }else{
...@@ -145,15 +145,13 @@ export default function rdbStoreBackupRestoreCallbackTest() { ...@@ -145,15 +145,13 @@ export default function rdbStoreBackupRestoreCallbackTest() {
expect(false).assertTrue() expect(false).assertTrue()
} }
} }
})
// RDB before restored, delete data // RDB before restored, delete data
let deleteData = new dataRdb.RdbPredicates("backupTest") let deleteData = new dataRdb.RdbPredicates("backupTest")
deleteData.equalTo("name", "zhangsan") deleteData.equalTo("name", "zhangsan")
await RdbStore.delete(deleteData) RdbStore.delete(deleteData).then(()=> {
RdbStore.restore(DATABASE_BACKUP_NAME, async (err, data) => {
// RDB restore function test
await RdbStore.restore(DATABASE_BACKUP_NAME, async (err, data) => {
if(err != null){ if(err != null){
expect(false).assertTrue() expect(false).assertTrue()
}else{ }else{
...@@ -188,10 +186,12 @@ export default function rdbStoreBackupRestoreCallbackTest() { ...@@ -188,10 +186,12 @@ export default function rdbStoreBackupRestoreCallbackTest() {
resultSet = null resultSet = null
RdbStore = null RdbStore = null
} }
})
done() done()
console.info(TAG + "************* RdbBackupRestoreCallbackTest_0100 end *************") console.info(TAG + "************* RdbBackupRestoreCallbackTest_0100 end *************")
}) })
})
})
})
/** /**
* @tc.name RDB Backup test * @tc.name RDB Backup test
...@@ -262,7 +262,7 @@ export default function rdbStoreBackupRestoreCallbackTest() { ...@@ -262,7 +262,7 @@ export default function rdbStoreBackupRestoreCallbackTest() {
// RDB restore function test, backup file // RDB restore function test, backup file
RdbStore.backup(DATABASE_BACKUP_NAME, (err, data) => { RdbStore.backup(DATABASE_BACKUP_NAME, (err, data) => {
if(err != null){ if(err != null){
expect(false).assertTrue(0) expect(false).assertTrue()
}else{ }else{
try{ try{
console.info(TAG + 'Backup database success') console.info(TAG + 'Backup database success')
...@@ -270,31 +270,33 @@ export default function rdbStoreBackupRestoreCallbackTest() { ...@@ -270,31 +270,33 @@ export default function rdbStoreBackupRestoreCallbackTest() {
}catch(err){ }catch(err){
expect(false).assertTrue(); expect(false).assertTrue();
} }
} dataRdb.deleteRdbStore(context, DATABASE_BACKUP_NAME).then(() => {
})
await dataRdb.deleteRdbStore(context, DATABASE_BACKUP_NAME).then(() => {
try{ try{
fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME) fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME)
}catch(err){ }catch(err){
console.info(TAG + 'error2 ' + err) console.info(TAG + 'error2 ' + err)
expect(true).assertTrue(); expect(true).assertTrue();
} }
})
RdbStore.backup(DATABASE_BACKUP_NAME, (err, data) => { RdbStore.backup(DATABASE_BACKUP_NAME, (err, data) => {
if(err != null){ if(err != null){
expect(false).assertTrue(0) console.info(`${TAG} Backup database second failed, error: message: ${err.message}`)
expect(true).assertTrue()
done();
console.info(TAG + "************* RdbBackupRestoreCallbackTest_0500 end *************")
}else{ }else{
try{ try{
console.info(TAG + 'Backup database success') console.info(TAG + 'Backup database second success')
fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME) fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME)
}catch(err){ }catch(err){
expect(false).assertTrue(); expect(false).assertTrue();
} }
} }
}) })
done() })
console.info(TAG + "************* RdbBackupRestoreCallbackTest_0500 end *************") }
})
}) })
/** /**
...@@ -332,22 +334,23 @@ export default function rdbStoreBackupRestoreCallbackTest() { ...@@ -332,22 +334,23 @@ export default function rdbStoreBackupRestoreCallbackTest() {
*/ */
it('RdbBackupRestoreCallbackTest_0700', 0, async function (done) { it('RdbBackupRestoreCallbackTest_0700', 0, async function (done) {
console.info(TAG + "************* RdbBackupRestoreCallbackTest_0700 start *************") console.info(TAG + "************* RdbBackupRestoreCallbackTest_0700 start *************")
RdbStore.backup(DATABASE_BACKUP_NAME, (err, data) => { let DATABASE_BACKUP_TEST_NAME = "BackupTest.db"
RdbStore.backup(DATABASE_BACKUP_TEST_NAME, (err, data) => {
if(err != null){ if(err != null){
expect(false).assertTrue() expect(false).assertTrue()
}else{ }else{
expect(true).assertTrue() expect(true).assertTrue()
} }
}) })
await dataRdb.deleteRdbStore(context, DATABASE_BACKUP_NAME).then(() => { await dataRdb.deleteRdbStore(context, DATABASE_BACKUP_TEST_NAME).then(() => {
try{ try{
fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME) fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_TEST_NAME)
}catch(err){ }catch(err){
expect(true).assertTrue(); expect(true).assertTrue();
} }
}) })
RdbStore.restore(DATABASE_BACKUP_NAME, (err, data) => { RdbStore.restore(DATABASE_BACKUP_TEST_NAME, (err, data) => {
if(err != null){ if(err != null){
expect(true).assertTrue() expect(true).assertTrue()
} }
......
...@@ -132,54 +132,50 @@ describe('rdbStoreBackupRestorePromiseTest', function () { ...@@ -132,54 +132,50 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console.info(TAG + "************* RdbBackupRestoreTest_0010 start *************") console.info(TAG + "************* RdbBackupRestoreTest_0010 start *************")
// RDB backup function test // RDB backup function test
let promiseBackup = RdbStore.backup(DATABASE_BACKUP_NAME) RdbStore.backup(DATABASE_BACKUP_NAME).then(async() => {
promiseBackup.then(() => {
try { try {
fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME) fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME)
fileio.accessSync(DATABASE_DIR + STORE_CONFIG.name) fileio.accessSync(DATABASE_DIR + STORE_CONFIG.name)
} catch (err) { } catch (err) {
console.info("RdbBackupRestoreTest_0010 backup success")
expect(false).assertTrue() expect(false).assertTrue()
} }
}).catch((err) => {
expect(false).assertTrue()
})
await promiseBackup
// RDB before restored, delete data // RDB before restored, delete data
let deleteData = new dataRdb.RdbPredicates("test") let deleteData = new dataRdb.RdbPredicates("test")
deleteData.equalTo("name", "zhangsan") deleteData.equalTo("name", "zhangsan")
await RdbStore.delete(deleteData) await RdbStore.delete(deleteData)
// RDB restore function test // RDB restore function test
let promiseRestore = RdbStore.restore(DATABASE_BACKUP_NAME) RdbStore.restore(DATABASE_BACKUP_NAME).then(async () => {
promiseRestore.then(() => {
try { try {
fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME) fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME)
expect(false).assertTrue() expect(false).assertTrue()
} catch (err) { } catch (err) {
console.info("RdbBackupRestoreTest_0010 restore success")
expect(true).assertTrue() expect(true).assertTrue()
} }
try { try {
fileio.accessSync(DATABASE_DIR + STORE_CONFIG.name) fileio.accessSync(DATABASE_DIR + STORE_CONFIG.name)
} catch (err) { } catch (err) {
console.info("RdbBackupRestoreTest_0010 restore success2")
expect(false).assertTrue() expect(false).assertTrue()
} }
}).catch((err) => {
expect(false).assertTrue()
})
await promiseRestore
// RDB after restored, data query test // RDB after restored, data query test
let predicates = new dataRdb.RdbPredicates("test") let predicates = new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
let resultSet = await RdbStore.query(predicates) RdbStore.query(predicates).then((resultSet)=>{
try { try {
console.info(TAG + "After restore resultSet query done") console.info(TAG + "After restore resultSet query done")
resultSet.goToFirstRow();
expect(true).assertEqual(resultSet.goToFirstRow()) expect(true).assertEqual(resultSet.goToFirstRow())
console.info("RdbBackupRestoreTest_0010 goto first row success")
const id = resultSet.getLong(resultSet.getColumnIndex("id")) const id = resultSet.getLong(resultSet.getColumnIndex("id"))
console.info("RdbBackupRestoreTest_0010 get dolumnindex id success")
const name = resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
console.info("RdbBackupRestoreTest_0010 get dolumnindex name success")
const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType")) const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
console.info(`RdbBackupRestoreTest_0010 id is ${id},name id ${name},blobType is ${blobType[0]}`)
expect(1).assertEqual(id) expect(1).assertEqual(id)
expect("zhangsan").assertEqual(name) expect("zhangsan").assertEqual(name)
expect(1).assertEqual(blobType[0]) expect(1).assertEqual(blobType[0])
...@@ -189,10 +185,22 @@ describe('rdbStoreBackupRestorePromiseTest', function () { ...@@ -189,10 +185,22 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
} }
resultSet = null resultSet = null
RdbStore = null RdbStore = null
done() done()
console.info(TAG + "************* RdbBackupRestoreTest_0010 end *************") console.info(TAG + "************* RdbBackupRestoreTest_0010 end *************")
}) })
}).catch((err) => {
console.info("RdbBackupRestoreTest_0010 restore error: " + err)
expect(false).assertTrue()
})
}).catch((err) => {
expect(false).assertTrue()
})
})
/** /**
* @tc.name RDB Backup test * @tc.name RDB Backup test
* @tc.number SUB_DDM_RDB_JS_RdbBackupRestoreTest_0020 * @tc.number SUB_DDM_RDB_JS_RdbBackupRestoreTest_0020
...@@ -298,24 +306,16 @@ describe('rdbStoreBackupRestorePromiseTest', function () { ...@@ -298,24 +306,16 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
*/ */
it('RdbBackupRestoreTest_0060', 0, async function (done) { it('RdbBackupRestoreTest_0060', 0, async function (done) {
console.info(TAG + "************* RdbBackupRestoreTest_0060 start *************") console.info(TAG + "************* RdbBackupRestoreTest_0060 start *************")
// Backup file is specified to database name // Backup file is specified to database name
await RdbStore.backup(STORE_CONFIG.name).then(() => { RdbStore.backup(STORE_CONFIG.name).then(() => {
console.info(TAG + 'Backup database finish') console.info(TAG + 'Backup database finish');
}).catch((err) => { expect(false).assertTrue() ;
expect(true).assertTrue()
})
// Backup file is specified to database name again
await RdbStore.backup(STORE_CONFIG.name).then(() => {
console.info(TAG + 'Backup database finish')
}).catch((err) => { }).catch((err) => {
expect(true).assertTrue(); console.info(TAG + "Backup database error");
}) expect(true).assertTrue() ;
done(); done();
console.info(TAG + "************* RdbBackupRestoreTest_0060 end *************")
}) })
})
/** /**
* @tc.name RDB BackupRestore test * @tc.name RDB BackupRestore test
* @tc.number SUB_DDM_RDB_JS_RdbBackupRestoreTest_0070 * @tc.number SUB_DDM_RDB_JS_RdbBackupRestoreTest_0070
...@@ -324,13 +324,12 @@ describe('rdbStoreBackupRestorePromiseTest', function () { ...@@ -324,13 +324,12 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it('RdbBackupRestoreTest_0070', 0, async function (done) { it('RdbBackupRestoreTest_0070', 0, async function (done) {
console.info(TAG + "************* RdbBackupRestoreTest_0070 start *************") console.info(TAG + "************* RdbBackupRestoreTest_0070 start *************")
await RdbStore.backup(DATABASE_BACKUP_NAME) await RdbStore.backup(DATABASE_BACKUP_NAME)
await dataRdb.deleteRdbStore(context, DATABASE_BACKUP_NAME).then(() => { await dataRdb.deleteRdbStore(context, DATABASE_BACKUP_NAME)
try{ try{
fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME) fileio.accessSync(DATABASE_DIR + DATABASE_BACKUP_NAME)
}catch(err){ }catch(err){
expect(true).assertTrue(); expect(true).assertTrue();
} }
})
await RdbStore.restore(DATABASE_BACKUP_NAME).catch((err) => { await RdbStore.restore(DATABASE_BACKUP_NAME).catch((err) => {
console.info(TAG + 'Restore fail: ' + err) console.info(TAG + 'Restore fail: ' + err)
expect(true).assertTrue(); expect(true).assertTrue();
......
...@@ -85,18 +85,16 @@ describe('rdbStoreDeleteTest', function () { ...@@ -85,18 +85,16 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除 //删除
{ {
let predicates = await new dataRdb.RdbPredicates('test') let predicates = new dataRdb.RdbPredicates('test')
let deletePromise = rdbStore.delete(predicates) rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => {
expect(3).assertEqual(ret) expect(3).assertEqual(ret)
console.info(TAG + 'Delete done: ' + ret) console.info(TAG + 'Delete done: ' + ret)
done()
console.info(TAG + '************* testRdbStoreDelete0001 end *************');
}).catch((err) => { }).catch((err) => {
expect(null).assertFail() expect(null).assertFail()
}) })
await deletePromise
} }
done()
console.info(TAG + '************* testRdbStoreDelete0001 end *************');
}) })
/** /**
...@@ -138,17 +136,15 @@ describe('rdbStoreDeleteTest', function () { ...@@ -138,17 +136,15 @@ describe('rdbStoreDeleteTest', function () {
{ {
let predicates = await new dataRdb.RdbPredicates('test') let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('name', 'zhangsan') predicates.equalTo('name', 'zhangsan')
let deletePromise = rdbStore.delete(predicates) rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => { expect(1).assertEqual(ret)
await expect(1).assertEqual(ret) console.info(TAG + 'Delete done: ' + ret)
await console.info(TAG + 'Delete done: ' + ret) done()
console.info(TAG + '************* testRdbStoreDelete0002 end *************');
}).catch((err) => { }).catch((err) => {
expect(null).assertFail() expect(null).assertFail()
}) })
await deletePromise
} }
done()
console.info(TAG + '************* testRdbStoreDelete0002 end *************');
}) })
/** /**
...@@ -185,27 +181,24 @@ describe('rdbStoreDeleteTest', function () { ...@@ -185,27 +181,24 @@ describe('rdbStoreDeleteTest', function () {
expect(1).assertEqual(resultSet.rowCount) expect(1).assertEqual(resultSet.rowCount)
} }
//删除 //删除
{
let predicates = await new dataRdb.RdbPredicates('test') let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('age', 28) predicates.equalTo('age', 28)
let deletePromise = rdbStore.delete(predicates) rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => {
expect(1).assertEqual(ret) expect(1).assertEqual(ret)
console.info(TAG + 'Delete done: ' + ret) console.info(TAG + 'Delete done: ' + ret)
}).catch((err) => {
expect(null).assertFail()
})
await deletePromise
}
//删除后查询 //删除后查询
{
let predicates = await new dataRdb.RdbPredicates('test') let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('age', 28) predicates.equalTo('age', 28)
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
}
done() done()
console.info(TAG + '************* testRdbStoreDelete0003 end *************'); console.info(TAG + '************* testRdbStoreDelete0003 end *************');
}).catch((err) => {
expect(null).assertFail()
})
}) })
/** /**
...@@ -247,16 +240,15 @@ describe('rdbStoreDeleteTest', function () { ...@@ -247,16 +240,15 @@ describe('rdbStoreDeleteTest', function () {
{ {
let predicates = await new dataRdb.RdbPredicates('test') let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('aaa id', 1) predicates.equalTo('aaa id', 1)
let deletePromise = rdbStore.delete(predicates) rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => {
console.info(TAG + 'delete done: ' + ret) console.info(TAG + 'delete done: ' + ret)
expect(null).assertFail() expect(null).assertFail()
}).catch((err) => { }).catch((err) => {
console.info(TAG + 'delete with wrong conditions') console.info(TAG + 'delete with wrong conditions')
done();
console.info(TAG + '************* testRdbStoreDelete0004 end *************');
}) })
} }
done()
console.info(TAG + '************* testRdbStoreDelete0004 end *************');
}) })
/** /**
...@@ -298,17 +290,16 @@ describe('rdbStoreDeleteTest', function () { ...@@ -298,17 +290,16 @@ describe('rdbStoreDeleteTest', function () {
{ {
let predicates = await new dataRdb.RdbPredicates('test') let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('name', 'lisi') predicates.equalTo('name', 'lisi')
let deletePromise = rdbStore.delete(predicates) rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => {
expect(2).assertEqual(ret) expect(2).assertEqual(ret)
console.info(TAG + 'Delete done: ' + ret) console.info(TAG + 'Delete done: ' + ret)
done()
console.info(TAG + '************* testRdbStoreDelete0005 end *************');
}).catch((err) => { }).catch((err) => {
expect(null).assertFail() expect(null).assertFail()
}) })
await deletePromise
} }
done()
console.info(TAG + '************* testRdbStoreDelete0005 end *************');
}) })
/** /**
...@@ -350,8 +341,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -350,8 +341,7 @@ describe('rdbStoreDeleteTest', function () {
//删除 //删除
try{ try{
let predicates = await new dataRdb.RdbPredicates('') let predicates = await new dataRdb.RdbPredicates('')
let deletePromise = rdbStore.delete(predicates) rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => {
console.info(TAG + 'delete done: ' + ret) console.info(TAG + 'delete done: ' + ret)
expect(null).assertFail() expect(null).assertFail()
}).catch((err) => { }).catch((err) => {
......
...@@ -25,6 +25,9 @@ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIM ...@@ -25,6 +25,9 @@ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIM
const STORE_CONFIG = { const STORE_CONFIG = {
name: "rdbstore.db", name: "rdbstore.db",
} }
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default function rdbStoreTest() { export default function rdbStoreTest() {
describe('rdbStoreTest', function () { describe('rdbStoreTest', function () {
beforeAll(async function () { beforeAll(async function () {
...@@ -54,18 +57,15 @@ describe('rdbStoreTest', function () { ...@@ -54,18 +57,15 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0001', 0, async function (done) { it('testRdbStore0001', 0, async function (done) {
console.info(TAG + "************* testRdbStore0001 start *************"); console.info(TAG + "************* testRdbStore0001 start *************");
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 1); await dataRdb.getRdbStore(STORE_CONFIG, 1).then(async (store) => {
storePromise.then(async (store) => {
try { try {
await console.info(TAG + "getRdbStore done: " + store); console.info(TAG + "getRdbStore done: " + store);
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
} }
}).catch((err) => { }).catch((err) => {
expect(null).assertFail(); expect(null).assertFail();
}) })
await storePromise
storePromise = null
done(); done();
console.info(TAG + "************* testRdbStore0001 end *************"); console.info(TAG + "************* testRdbStore0001 end *************");
}) })
...@@ -80,7 +80,7 @@ describe('rdbStoreTest', function () { ...@@ -80,7 +80,7 @@ describe('rdbStoreTest', function () {
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 2); let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 2);
storePromise.then(async (store) => { storePromise.then(async (store) => {
try { try {
await console.info(TAG + "getRdbStore done: " + store); console.info(TAG + "getRdbStore done: " + store);
await store.executeSql(CREATE_TABLE_TEST); await store.executeSql(CREATE_TABLE_TEST);
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
...@@ -105,16 +105,20 @@ describe('rdbStoreTest', function () { ...@@ -105,16 +105,20 @@ describe('rdbStoreTest', function () {
let storeConfig = { let storeConfig = {
name: "/wrong/rdbstore.db", name: "/wrong/rdbstore.db",
} }
let storePromise = dataRdb.getRdbStore(storeConfig, 4); try{
storePromise.then(async (ret) => { dataRdb.getRdbStore(storeConfig, 4).then(async (ret) => {
await console.info(TAG + "getRdbStore done" + ret); console.info(TAG + "getRdbStore done" + ret);
expect(null).assertFail(); expect(null).assertFail();
}).catch((err) => { }).catch((err) => {
console.info(TAG + "getRdbStore with wrong path"); console.info(TAG + "getRdbStore with wrong path");
}) })
storePromise = null expect(false).assertTrue();
}catch(error){
console.info(TAG + `catch err: failed: err: code= ${error.code}, message = ${error.message}`)
expect(error.code).assertEqual("401")
done(); done();
console.info(TAG + "************* testRdbStore0003 end *************"); console.info(TAG + "************* testRdbStore0003 end *************");
}
}) })
/** /**
...@@ -124,22 +128,13 @@ describe('rdbStoreTest', function () { ...@@ -124,22 +128,13 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0004', 0, async function (done) { it('testRdbStore0004', 0, async function (done) {
console.info(TAG + "************* testRdbStore0004 start *************"); console.info(TAG + "************* testRdbStore0004 start *************");
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 1); try{
storePromise.then(async (store) => { let store = await dataRdb.getRdbStore(STORE_CONFIG, 1)
try {
await store.executeSql(CREATE_TABLE_TEST); await store.executeSql(CREATE_TABLE_TEST);
await dataRdb.deleteRdbStore("rdbstore.db").then(()=>{ await dataRdb.deleteRdbStore("rdbstore.db")
console.info(TAG + "deleteRdbStore promise done" + store); }catch (e) {
expect(true).assertTrue();
})
} catch (e) {
expect(null).assertFail(); expect(null).assertFail();
} }
}).catch((err) => {
expect(null).assertFail();
})
await storePromise
storePromise = null
done(); done();
console.info(TAG + "************* testRdbStore0004 end *************"); console.info(TAG + "************* testRdbStore0004 end *************");
}) })
...@@ -151,24 +146,14 @@ describe('rdbStoreTest', function () { ...@@ -151,24 +146,14 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0005', 0, async function (done) { it('testRdbStore0005', 0, async function (done) {
console.info(TAG + "************* testRdbStore0005 start *************"); console.info(TAG + "************* testRdbStore0005 start *************");
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 2);
storePromise.then(async (store) => {
try { try {
let store = await dataRdb.getRdbStore(STORE_CONFIG, 2);
console.info(TAG + "Get rdbstore success")
await store.executeSql(CREATE_TABLE_TEST); await store.executeSql(CREATE_TABLE_TEST);
let deletePromise = dataRdb.deleteRdbStore("rdbstore.db") await dataRdb.deleteRdbStore("rdbstore.db")
deletePromise.then(()=>{
console.info(TAG + "deleteRdbStore promise done" + store);
expect(true).assertTrue();
})
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
} }
}).catch((err) => {
expect(null).assertFail();
})
await storePromise
storePromise = null
done(); done();
console.info(TAG + "************* testRdbStore0005 end *************"); console.info(TAG + "************* testRdbStore0005 end *************");
}) })
...@@ -185,20 +170,14 @@ describe('rdbStoreTest', function () { ...@@ -185,20 +170,14 @@ describe('rdbStoreTest', function () {
const STORE_CONFIG= { const STORE_CONFIG= {
name: "rdbstorecontext.db", name: "rdbstorecontext.db",
} }
console.info(TAG + "first") rdbstore = await dataRdb.getRdbStore(context,STORE_CONFIG, 1)
await dataRdb.getRdbStore(context,STORE_CONFIG, 1).then((data) => {
console.info(TAG + "Get rdbstore success") console.info(TAG + "Get rdbstore success")
rdbstore = data;
expect(rdbstore != null).assertTrue(); expect(rdbstore != null).assertTrue();
}).catch((errInfo) => { await dataRdb.deleteRdbStore(STORE_CONFIG.name)
console.info(TAG + "Get rdbstore fail " + errInfo)
expect(null).assertFail();
})
}catch(err){ }catch(err){
console.info(TAG + "Get rdbstore fail catch err: " + err) console.info(TAG + "Get rdbstore fail catch err: " + err)
expect(null).assertFail() expect(null).assertFail()
} }
await dataRdb.deleteRdbStore(STORE_CONFIG.name)
rdbstore = null; rdbstore = null;
done(); done();
console.info(TAG + "************* testRdbStore0006 end *************"); console.info(TAG + "************* testRdbStore0006 end *************");
...@@ -216,20 +195,14 @@ describe('rdbStoreTest', function () { ...@@ -216,20 +195,14 @@ describe('rdbStoreTest', function () {
const STORE_CONFIG = { const STORE_CONFIG = {
name: "rdbstorecontext.db", name: "rdbstorecontext.db",
} }
console.info(TAG + "first") rdbstore = await dataRdb.getRdbStore(contextApplication,STORE_CONFIG, 1)
await dataRdb.getRdbStore(contextApplication,STORE_CONFIG, 1).then((data) => {
console.info(TAG + "Get rdbstore success") console.info(TAG + "Get rdbstore success")
rdbstore = data;
expect(rdbstore != null).assertTrue(); expect(rdbstore != null).assertTrue();
}).catch((errInfo) => { await dataRdb.deleteRdbStore(STORE_CONFIG.name)
console.info(TAG + "Get rdbstore fail " + errInfo)
expect(null).assertFail();
})
}catch(err){ }catch(err){
console.info(TAG + "Get rdbstore fail catch err: " + err) console.info(TAG + "Get rdbstore fail catch err: " + err)
expect(null).assertFail() expect(null).assertFail()
} }
await dataRdb.deleteRdbStore(STORE_CONFIG.name)
rdbstore = null; rdbstore = null;
done(); done();
console.info(TAG + "************* testRdbStore0007 end *************"); console.info(TAG + "************* testRdbStore0007 end *************");
...@@ -242,20 +215,15 @@ describe('rdbStoreTest', function () { ...@@ -242,20 +215,15 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0008', 0, async function (done) { it('testRdbStore0008', 0, async function (done) {
console.info(TAG + "************* testRdbStore0008 start *************"); console.info(TAG + "************* testRdbStore0008 start *************");
let rdbstore = null; dataRdb.getRdbStore(context,STORE_CONFIG, 1, async (err,data) => {
dataRdb.getRdbStore(context,STORE_CONFIG, 1, (data,err) => { console.info(TAG + "getRdbStore finish")
if(err != undefined){ console.info(TAG + "getRdbStore success: " + data)
expect(null).assertFail() expect(data != null).assertTrue();
}else{ await dataRdb.deleteRdbStore(contextApplication,STORE_CONFIG.name)
rdbstore = data;
console.info(TAG + "getRdbStore success: " + rdbstore)
expect(rdbstore).assertNotNull();
}
});
await dataRdb.deleteRdbStore(context,STORE_CONFIG.name)
rdbstore = null;
done(); done();
console.info(TAG + "************* testRdbStore0008 end *************"); console.info(TAG + "************* testRdbStore0008 end *************");
});
await sleep(1000)
}) })
/** /**
...@@ -265,21 +233,15 @@ describe('rdbStoreTest', function () { ...@@ -265,21 +233,15 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0009', 0, async function(done){ it('testRdbStore0009', 0, async function(done){
console.info(TAG + "************* testRdbStore0009 start *************"); console.info(TAG + "************* testRdbStore0009 start *************");
let rdbstore = null; dataRdb.getRdbStore(contextApplication,STORE_CONFIG, 1, async (err,data) => {
dataRdb.getRdbStore(contextApplication,STORE_CONFIG, 1, (data,err) => { console.info(TAG + "getRdbStore finish")
if(err != undefined){ console.info(TAG + "getRdbStore success: " + data)
expect(null).assertFail() expect(data != null).assertTrue();
}else{
rdbstore = data;
console.info(TAG + "getRdbStore success: " + rdbstore)
expect(rdbstore).assertNotNull();
}
});
await dataRdb.deleteRdbStore(contextApplication,STORE_CONFIG.name) await dataRdb.deleteRdbStore(contextApplication,STORE_CONFIG.name)
rdbstore = null;
done(); done();
console.info(TAG + "************* testRdbStore0009 end *************"); console.info(TAG + "************* testRdbStore0009 end *************");
});
await sleep(1000)
}) })
console.info(TAG + "*************Unit Test End*************"); console.info(TAG + "*************Unit Test End*************");
......
...@@ -178,13 +178,13 @@ describe('rdbStoreV9Test', function () { ...@@ -178,13 +178,13 @@ describe('rdbStoreV9Test', function () {
}else{ }else{
console.info(TAG + "create table success") console.info(TAG + "create table success")
} }
done(); dataRdb.deleteRdbStore(context,"secure.db").then(()=>{
}); console.info(TAG + "Delete rdbstore success")
await dataRdb.deleteRdbStore(context,"secure.db");
await sleep(1000)
done(); done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0100 end *************"); console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0100 end *************");
}) })
});
})
/** /**
* @tc.name rdb store getRdbStoreV9 with securityLevel S2 * @tc.name rdb store getRdbStoreV9 with securityLevel S2
...@@ -205,13 +205,12 @@ describe('rdbStoreV9Test', function () { ...@@ -205,13 +205,12 @@ describe('rdbStoreV9Test', function () {
}else{ }else{
console.info(TAG + "create table success") console.info(TAG + "create table success")
} }
done(); dataRdb.deleteRdbStore(context, "secure.db").then(() => {
});
await dataRdb.deleteRdbStore(context,"secure.db");
await sleep(1000)
done(); done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0200 end *************"); console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0200 end *************");
}) })
});
})
/** /**
* @tc.name rdb store getRdbStoreV9 with securityLevel S3 * @tc.name rdb store getRdbStoreV9 with securityLevel S3
...@@ -232,13 +231,12 @@ describe('rdbStoreV9Test', function () { ...@@ -232,13 +231,12 @@ describe('rdbStoreV9Test', function () {
}else{ }else{
console.info(TAG + "create table success") console.info(TAG + "create table success")
} }
done(); dataRdb.deleteRdbStore(context, "secure.db").then(() => {
});
await dataRdb.deleteRdbStore(context,"secure.db");
await sleep(1000)
done(); done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0300 end *************"); console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0300 end *************");
}) })
});
})
/** /**
* @tc.name rdb store getRdbStoreV9 with securityLevel S4 * @tc.name rdb store getRdbStoreV9 with securityLevel S4
...@@ -259,13 +257,12 @@ describe('rdbStoreV9Test', function () { ...@@ -259,13 +257,12 @@ describe('rdbStoreV9Test', function () {
}else{ }else{
console.info(TAG + "get rdb store success") console.info(TAG + "get rdb store success")
} }
done(); dataRdb.deleteRdbStore(context,"secure.db").then(() => {
});
await dataRdb.deleteRdbStore(context,"secure.db");
await sleep(1000)
done(); done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0400 end *************"); console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTOREV9_CALLBACK_0400 end *************");
}) })
});
})
/** /**
* @tc.name rdb store deleteRdbStoreV9 * @tc.name rdb store deleteRdbStoreV9
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册