From 0f3e22d2c153b3c37ee66fb072a9b43f6bf9ff12 Mon Sep 17 00:00:00 2001 From: yuxiaoya2 Date: Tue, 28 Mar 2023 11:28:13 +0800 Subject: [PATCH] =?UTF-8?q?rdb=E7=94=A8=E4=BE=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yuxiaoya2 Change-Id: Ie037ec55cb4101e2bd91227131d6b2644e6712cf --- .../test/RdbStoreSyncFirstLevelJsunit.test.js | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/distributeddatamgr/jstest/distributed_rdb_store/client/hap/src/main/js/test/RdbStoreSyncFirstLevelJsunit.test.js b/distributeddatamgr/jstest/distributed_rdb_store/client/hap/src/main/js/test/RdbStoreSyncFirstLevelJsunit.test.js index 55a2f3b..fb2ba86 100644 --- a/distributeddatamgr/jstest/distributed_rdb_store/client/hap/src/main/js/test/RdbStoreSyncFirstLevelJsunit.test.js +++ b/distributeddatamgr/jstest/distributed_rdb_store/client/hap/src/main/js/test/RdbStoreSyncFirstLevelJsunit.test.js @@ -1385,7 +1385,65 @@ export default function rdbSyncFirstLevelTest(){ } console.info(logTag + "************* testRdbSyncTest0170 end *************"); }) + + /** + * @tc.number SUB_DISTRIBUTEDDATAMGR_SyncRDBTest_1800 + * @tc.name testRdbSyncTest0180 + * @tc.desc Server rdbStore Insert first and synchronize, Pass null in synchronous mode + */ + it("testRdbSyncTest0180", 0, async function (done) { + console.info(logTag + "testRdbSyncTest0180 start"); + var u8 = new Uint8Array([1, 2, 3]); + { + const valueBucket = { + "name": "zhangsan", + "age": 18, + "salary": 100.5, + "blobType": u8 + } + await rdbStore.insert("test", valueBucket); + console.info("testRdbSyncTest0180 insert success"); + } + let predicates = new data_Rdb.RdbPredicates('test'); + predicates.equalTo("name", "zhangsan"); + let resultSet = await rdbStore.query(predicates); + try { + expect(true).assertEqual(resultSet.goToFirstRow()); + const id = resultSet.getLong(resultSet.getColumnIndex("id")); + const name = resultSet.getString(resultSet.getColumnIndex("name")); + console.info(logTag + "testRdbSyncTest0180 id=" + id + ", name=" + name); + expect("zhangsan").assertEqual(name); + } catch (e) { + console.info("testRdbSyncTest0180 insert error " + e); + expect().assertFail(); + } + resultSet = null; + try { + predicates.inDevices(syncDeviceIds); + let promise = rdbStore.sync(null, predicates); + promise.then((result) => { + console.log('testRdbSyncTest0180 sync done.'); + for (let i = 0; i < result.length; i++) { + console.log('testRdbSyncTest0180 device=' + result[i][0] + ' status=' + result[i][1]); + let status = result[i][1]; + expect(status == 0).assertFail(); + } + done(); + }).catch((err) => { + console.log('testRdbSyncTest0180 sync failed' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + } catch (error) { + console.log('testRdbSyncTest0180 sync failed error.code message: ' + error.code + error.message); + expect(error.code == 401).assertTrue(); + done(); + } + // await promise; + console.info(logTag + "************* testRdbSyncTest0180 end *************"); + }) + /** * @tc.number SUB_DISTRIBUTEDDATAMGR_SyncRDBTest_1900 * @tc.name testRdbSyncTest0190