Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
09888285
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
09888285
编写于
2月 27, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 27, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7725 【Distributeddatamgr】【master】master用例修改,优化执行时序
Merge pull request !7725 from yanglifeng/master
上级
1fe1facf
99217fa9
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
257 addition
and
307 deletion
+257
-307
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/List.test.js
...onalStoretest/RdbJstest/hap/src/main/js/test/List.test.js
+6
-5
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreBackupRestoreCallbackJsunit.test.js
.../main/js/test/RdbstoreBackupRestoreCallbackJsunit.test.js
+41
-51
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreBackupRestoreWithFAContextJsunit.test.js
.../js/test/RdbstoreBackupRestoreWithFAContextJsunit.test.js
+89
-102
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/List.test.js
...t/relationalStoreJstest/hap/src/main/js/test/List.test.js
+5
-4
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreBackupRestoreCallbackJsunit.test.js
...s/test/RelationalStoreBackupRestoreCallbackJsunit.test.js
+81
-94
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreBackupRestoreWithFAContextJsunit.test.js
...t/RelationalStoreBackupRestoreWithFAContextJsunit.test.js
+18
-32
distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/relationalStoreEtsunit.test.ets
...t/entry/src/main/ets/test/relationalStoreEtsunit.test.ets
+17
-19
未找到文件。
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/List.test.js
浏览文件 @
09888285
/*
/*
* Copyright (c) 2021-202
2
Huawei Device Co., Ltd.
* Copyright (c) 2021-202
3
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
...
@@ -12,8 +12,7 @@
...
@@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import
rdbStoreBackupRestoreCallbackTest
from
'
./RdbstoreBackupRestoreCallbackJsunit.test.js
'
import
rdbStoreBackupRestoreWithFAContextTest
from
'
./RdbstoreBackupRestoreWithFAContextJsunit.test.js
'
import
rdbStoreDeleteTest
from
'
./RdbstoreDeleteJsunit.test.js
'
import
rdbStoreDeleteTest
from
'
./RdbstoreDeleteJsunit.test.js
'
import
rdbStoreDistributedTest
from
'
./RdbStoreDistributedJsunit.test.js
'
import
rdbStoreDistributedTest
from
'
./RdbStoreDistributedJsunit.test.js
'
import
rdbstoreInsertTest
from
'
./RdbstoreInsertJsunit.test.js
'
import
rdbstoreInsertTest
from
'
./RdbstoreInsertJsunit.test.js
'
...
@@ -27,9 +26,9 @@ import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js'
...
@@ -27,9 +26,9 @@ import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js'
import
rdbstoreQueryTest
from
'
./RdbstoreQuery.test.js
'
import
rdbstoreQueryTest
from
'
./RdbstoreQuery.test.js
'
import
rdbStoreEncryptionTest
from
'
./RdbstoreEncryptionJsunit.test.js
'
import
rdbStoreEncryptionTest
from
'
./RdbstoreEncryptionJsunit.test.js
'
import
rdbStorePredicatesComplexFiledTest
from
'
./RdbstorePredicatesComplexFiledJsunit.test.js
'
import
rdbStorePredicatesComplexFiledTest
from
'
./RdbstorePredicatesComplexFiledJsunit.test.js
'
import
rdbStoreBackupRestoreWithFAContextTest
from
'
./RdbstoreBackupRestoreWithFAContextJsunit.test.js
'
import
rdbStoreBackupRestoreCallbackTest
from
'
./RdbstoreBackupRestoreCallbackJsunit.test.js
'
export
default
function
testsuite
()
{
export
default
function
testsuite
()
{
rdbStoreBackupRestoreCallbackTest
()
rdbStoreBackupRestoreWithFAContextTest
()
rdbStoreDeleteTest
()
rdbStoreDeleteTest
()
rdbStoreDistributedTest
()
rdbStoreDistributedTest
()
rdbstoreInsertTest
()
rdbstoreInsertTest
()
...
@@ -43,4 +42,6 @@ export default function testsuite() {
...
@@ -43,4 +42,6 @@ export default function testsuite() {
rdbstoreQueryTest
()
rdbstoreQueryTest
()
rdbStoreEncryptionTest
()
rdbStoreEncryptionTest
()
rdbStorePredicatesComplexFiledTest
()
rdbStorePredicatesComplexFiledTest
()
rdbStoreBackupRestoreWithFAContextTest
()
rdbStoreBackupRestoreCallbackTest
()
}
}
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreBackupRestoreCallbackJsunit.test.js
浏览文件 @
09888285
...
@@ -146,7 +146,6 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -146,7 +146,6 @@ export default function rdbStoreBackupRestoreCallbackTest() {
}
}
}
}
// 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
"
)
...
@@ -159,7 +158,7 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -159,7 +158,7 @@ export default function rdbStoreBackupRestoreCallbackTest() {
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
catch
(
err
)
{
}
catch
(
err
)
{
expect
(
true
).
assertTrue
(
)
console
.
info
(
TAG
+
"
rdb restore1 done
"
)
}
}
try
{
try
{
...
@@ -275,14 +274,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -275,14 +274,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
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
();
}
}
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
if
(
err
!=
null
){
console
.
info
(
`
${
TAG
}
Backup database second failed, error: message:
${
err
.
message
}
`
)
console
.
info
(
`
${
TAG
}
Backup database second failed`
)
expect
(
true
).
assertTrue
()
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
}
else
{
}
else
{
try
{
try
{
console
.
info
(
TAG
+
'
Backup database second success
'
)
console
.
info
(
TAG
+
'
Backup database second success
'
)
...
@@ -291,12 +286,12 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -291,12 +286,12 @@ export default function rdbStoreBackupRestoreCallbackTest() {
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
}
}
}
}
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
})
})
})
})
}
}
})
})
})
})
/**
/**
...
@@ -309,23 +304,17 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -309,23 +304,17 @@ export default function rdbStoreBackupRestoreCallbackTest() {
// Backup file is specified to database name
// Backup file is specified to database name
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
!=
null
).
assertTrue
()
expect
(
true
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup1 done
"
)
}
else
{
expect
(
false
).
assertTrue
()
}
})
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
!=
null
).
assertTrue
()
expect
(
true
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup2 done
"
)
}
else
{
expect
(
false
).
assertTrue
()
}
})
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0600 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0600 end *************
"
)
})
})
})
})
/**
/**
* @tc.name RDB BackupRestore test
* @tc.name RDB BackupRestore test
...
@@ -335,27 +324,23 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -335,27 +324,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 *************
"
)
let
DATABASE_BACKUP_TEST_NAME
=
"
BackupTest.db
"
let
DATABASE_BACKUP_TEST_NAME
=
"
BackupTest.db
"
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
async
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
==
null
).
assertTrue
()
expect
(
false
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 backup done
"
)
}
else
{
expect
(
true
).
assertTrue
()
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
,
()
=>
{
}
try
{
})
await
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
).
then
(()
=>
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_TEST_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_TEST_NAME
)
}
catch
(
err
)
{
}
catch
(
err
)
{
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 deleteRdbStore done
"
)
}
}
})
RdbStore
.
restore
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
RdbStore
.
restore
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
!=
null
).
assertTrue
()
expect
(
true
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 restore done
"
)
}
})
done
();
done
();
})
})
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 end *************
"
)
})
})
...
@@ -394,9 +379,11 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -394,9 +379,11 @@ export default function rdbStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
})
ReStoreCallbackTest
([
DATABASE_BACKUP_NAME
])
ReStoreCallbackTest
([
DATABASE_BACKUP_NAME
])
done
();
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1000 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1000 end *************
"
)
})
})
...
@@ -411,9 +398,11 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -411,9 +398,11 @@ export default function rdbStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
})
ReStoreCallbackTest
()
ReStoreCallbackTest
()
done
();
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1100 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1100 end *************
"
)
})
})
...
@@ -428,9 +417,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -428,9 +417,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
})
BackupCallbackTest
(
DATABASE_BACKUP_NAME
)
BackupCallbackTest
(
DATABASE_BACKUP_NAME
)
done
();
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1200 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1200 end *************
"
)
})
})
...
@@ -453,10 +443,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
...
@@ -453,10 +443,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
}
}
})
})
}
}
})
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1300 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1300 end *************
"
)
})
})
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
)
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
)
})
})
}
}
\ No newline at end of file
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreBackupRestoreWithFAContextJsunit.test.js
浏览文件 @
09888285
...
@@ -12,14 +12,14 @@
...
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
dataRdb
from
'
@ohos.data.rdb
'
import
dataRdb
from
'
@ohos.data.rdb
'
import
abilityFeatureAbility
from
'
@ohos.ability.featureAbility
'
import
abilityFeatureAbility
from
'
@ohos.ability.featureAbility
'
import
fileio
from
'
@ohos.fileio
'
import
fileio
from
'
@ohos.fileio
'
const
TAG
=
"
[RDB_JSKITS_TEST]
"
const
TAG
=
"
[RDB_JSKITS_TEST]
"
const
CREATE_TABLE_TEST
=
"
CREATE TABLE IF NOT EXISTS test (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
const
CREATE_TABLE_TEST
=
"
CREATE TABLE IF NOT EXISTS test (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER,
"
+
"
salary REAL,
"
+
"
blobType BLOB)
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER,
"
+
"
salary REAL,
"
+
"
blobType BLOB)
"
const
DATABASE_DIR
=
"
/data/storage/el2/database/entry/rdb/
"
const
DATABASE_DIR
=
"
/data/storage/el2/database/entry/rdb/
"
var
RdbStore
var
RdbStore
var
context
var
context
...
@@ -72,7 +72,7 @@ async function BackupTest(backupName) {
...
@@ -72,7 +72,7 @@ async function BackupTest(backupName) {
expect
(
true
).
assertTrue
()
expect
(
true
).
assertTrue
()
})
})
await
promiseRestore
await
promiseRestore
}
catch
(
errInfo
)
{
}
catch
(
errInfo
)
{
console
.
info
(
TAG
+
"
BackupTest error:
"
+
errInfo
)
console
.
info
(
TAG
+
"
BackupTest error:
"
+
errInfo
)
expect
(
true
).
assertTrue
()
expect
(
true
).
assertTrue
()
}
}
...
@@ -90,7 +90,7 @@ async function ReStoreTest(restoreName) {
...
@@ -90,7 +90,7 @@ async function ReStoreTest(restoreName) {
expect
(
true
).
assertTrue
()
expect
(
true
).
assertTrue
()
})
})
await
promiseRestore
await
promiseRestore
}
catch
(
errInfo
)
{
}
catch
(
errInfo
)
{
console
.
info
(
TAG
+
"
ReStoreTest error:
"
+
errInfo
)
console
.
info
(
TAG
+
"
ReStoreTest error:
"
+
errInfo
)
expect
(
true
).
assertTrue
()
expect
(
true
).
assertTrue
()
}
}
...
@@ -99,7 +99,7 @@ async function ReStoreTest(restoreName) {
...
@@ -99,7 +99,7 @@ async function ReStoreTest(restoreName) {
}
}
export
default
function
rdbStoreBackupRestorePromiseTest
()
{
export
default
function
rdbStoreBackupRestorePromiseTest
()
{
describe
(
'
rdbStoreBackupRestorePromiseTest
'
,
function
()
{
describe
(
'
rdbStoreBackupRestorePromiseTest
'
,
function
()
{
beforeAll
(
async
function
()
{
beforeAll
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeAll
'
)
console
.
info
(
TAG
+
'
beforeAll
'
)
})
})
...
@@ -132,7 +132,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -132,7 +132,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0010 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0010 start *************
"
)
// RDB backup function test
// RDB backup function test
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
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
)
...
@@ -146,13 +146,12 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -146,13 +146,12 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
await
RdbStore
.
delete
(
deleteData
)
await
RdbStore
.
delete
(
deleteData
)
// RDB restore function test
// RDB restore function test
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
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
"
)
console
.
info
(
"
RdbBackupRestoreTest_0010 restore success
"
)
expect
(
true
).
assertTrue
()
}
}
try
{
try
{
...
@@ -164,7 +163,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -164,7 +163,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
// 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
"
)
RdbStore
.
query
(
predicates
).
then
((
resultSet
)
=>
{
let
resultSet
=
await
RdbStore
.
query
(
predicates
)
try
{
try
{
console
.
info
(
TAG
+
"
After restore resultSet query done
"
)
console
.
info
(
TAG
+
"
After restore resultSet query done
"
)
resultSet
.
goToFirstRow
();
resultSet
.
goToFirstRow
();
...
@@ -183,24 +182,13 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -183,24 +182,13 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0010 accessSync err4:
'
+
err
)
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0010 accessSync err4:
'
+
err
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
resultSet
=
null
resultSet
.
close
()
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
...
@@ -269,33 +257,32 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -269,33 +257,32 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
// RDB restore function test, backup file
// RDB restore function test, backup file
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(()
=>
{
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(()
=>
{
try
{
try
{
console
.
info
(
TAG
+
'
Backup database success
'
)
console
.
info
(
TAG
+
'
Backup database 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
();
}
}
}).
then
(()
=>
{
}).
then
(()
=>
{
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_NAME
).
then
(()
=>
{
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
+
'
RdbBackupRestoreTest_0050 deleteRdbStore done
'
)
expect
(
true
).
assertTrue
();
}
}
})
})
}).
then
(()
=>
{
}).
then
(()
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(()
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(()
=>
{
try
{
try
{
console
.
info
(
TAG
+
'
Backup database success
'
)
console
.
info
(
TAG
+
'
Backup database success
'
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
info
(
TAG
+
'
error3
'
+
err
)
console
.
info
(
TAG
+
'
error3
'
+
err
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
done
()
})
})
})
})
done
()
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0050 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0050 end *************
"
)
})
})
...
@@ -308,11 +295,11 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -308,11 +295,11 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
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
RdbStore
.
backup
(
STORE_CONFIG
.
name
).
then
(()
=>
{
RdbStore
.
backup
(
STORE_CONFIG
.
name
).
then
(()
=>
{
console
.
info
(
TAG
+
'
Backup database finish
'
);
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0060 Backup database err
'
);
expect
(
false
).
assertTrue
()
;
expect
(
false
).
assertTrue
();
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Backup database error
"
);
console
.
info
(
TAG
+
"
RdbBackupRestoreTest_0060 Backup database done
"
);
expect
(
true
).
assertTrue
()
;
expect
(
err
!=
null
).
assertTrue
()
;
done
();
done
();
})
})
})
})
...
@@ -325,14 +312,14 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -325,14 +312,14 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
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
)
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
(
);
console
.
info
(
TAG
+
"
RdbBackupRestoreTest_0070 deleteRdbStore done
"
);
}
}
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
'
)
expect
(
true
).
assertTrue
();
expect
(
err
!=
null
).
assertTrue
();
})
})
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 end *************
"
)
...
@@ -370,7 +357,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -370,7 +357,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
([
DATABASE_BACKUP_NAME
])
await
ReStoreTest
([
DATABASE_BACKUP_NAME
])
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 end *************
"
)
})
})
...
@@ -383,7 +370,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -383,7 +370,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0110
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0110
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
()
await
ReStoreTest
()
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 end *************
"
)
})
})
...
@@ -396,7 +383,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -396,7 +383,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0120
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0120
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
BackupTest
(
DATABASE_BACKUP_NAME
)
await
BackupTest
(
DATABASE_BACKUP_NAME
)
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 end *************
"
)
})
})
...
@@ -410,7 +397,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
...
@@ -410,7 +397,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
ReStoreTest
(
DATABASE_BACKUP_NAME
)
await
ReStoreTest
(
DATABASE_BACKUP_NAME
)
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 end *************
"
)
})
})
...
...
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/List.test.js
浏览文件 @
09888285
...
@@ -12,8 +12,7 @@
...
@@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import
relationalStoreBackupRestoreCallbackTest
from
'
./RelationalStoreBackupRestoreCallbackJsunit.test.js
'
import
relationalStoreBackupRestoreWithFAContextTest
from
'
./RelationalStoreBackupRestoreWithFAContextJsunit.test.js
'
import
relationalStoreDeleteTest
from
'
./RelationalStoreDeleteJsunit.test.js
'
import
relationalStoreDeleteTest
from
'
./RelationalStoreDeleteJsunit.test.js
'
import
relationalStoreDistributedTest
from
'
./RelationalStoreDistributedJsunit.test.js
'
import
relationalStoreDistributedTest
from
'
./RelationalStoreDistributedJsunit.test.js
'
import
relationalStoreInsertTest
from
'
./RelationalStoreInsertJsunit.test.js
'
import
relationalStoreInsertTest
from
'
./RelationalStoreInsertJsunit.test.js
'
...
@@ -27,9 +26,9 @@ import relationalStoreUpdateTest from './RelationalStoreUpdateJsunit.test.js'
...
@@ -27,9 +26,9 @@ import relationalStoreUpdateTest from './RelationalStoreUpdateJsunit.test.js'
import
relationalStoreQueryTest
from
'
./RelationalStoreQuery.test.js
'
import
relationalStoreQueryTest
from
'
./RelationalStoreQuery.test.js
'
import
relationalStoreEncryptionTest
from
'
./RelationalStoreEncryptionJsunit.test.js
'
import
relationalStoreEncryptionTest
from
'
./RelationalStoreEncryptionJsunit.test.js
'
import
relationalStorePredicatesComplexFiledTest
from
'
./RelationalStorePredicatesComplexFiledJsunit.test.js
'
import
relationalStorePredicatesComplexFiledTest
from
'
./RelationalStorePredicatesComplexFiledJsunit.test.js
'
import
relationalStoreBackupRestoreWithFAContextTest
from
'
./RelationalStoreBackupRestoreWithFAContextJsunit.test.js
'
import
relationalStoreBackupRestoreCallbackTest
from
'
./RelationalStoreBackupRestoreCallbackJsunit.test.js
'
export
default
function
testsuite
()
{
export
default
function
testsuite
()
{
relationalStoreBackupRestoreCallbackTest
()
relationalStoreBackupRestoreWithFAContextTest
()
relationalStoreDeleteTest
()
relationalStoreDeleteTest
()
relationalStoreDistributedTest
()
relationalStoreDistributedTest
()
relationalStoreInsertTest
()
relationalStoreInsertTest
()
...
@@ -43,4 +42,6 @@ export default function testsuite() {
...
@@ -43,4 +42,6 @@ export default function testsuite() {
relationalStoreQueryTest
()
relationalStoreQueryTest
()
relationalStoreEncryptionTest
()
relationalStoreEncryptionTest
()
relationalStorePredicatesComplexFiledTest
()
relationalStorePredicatesComplexFiledTest
()
relationalStoreBackupRestoreWithFAContextTest
()
relationalStoreBackupRestoreCallbackTest
()
}
}
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreBackupRestoreCallbackJsunit.test.js
浏览文件 @
09888285
...
@@ -19,7 +19,7 @@ import fileio from '@ohos.fileio'
...
@@ -19,7 +19,7 @@ import fileio from '@ohos.fileio'
const
TAG
=
"
[RelationalStore_JSKITS_TEST]
"
const
TAG
=
"
[RelationalStore_JSKITS_TEST]
"
const
CREATE_TABLE_TEST
=
"
CREATE TABLE IF NOT EXISTS backupTest (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
const
CREATE_TABLE_TEST
=
"
CREATE TABLE IF NOT EXISTS backupTest (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER,
"
+
"
salary REAL,
"
+
"
blobType BLOB)
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER,
"
+
"
salary REAL,
"
+
"
blobType BLOB)
"
const
DATABASE_DIR
=
"
/data/storage/el2/database/entry/rdb/
"
const
DATABASE_DIR
=
"
/data/storage/el2/database/entry/rdb/
"
var
RdbStore
var
RdbStore
var
context
=
ability_featureAbility
.
getContext
()
var
context
=
ability_featureAbility
.
getContext
()
...
@@ -135,7 +135,8 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -135,7 +135,8 @@ export default function relationalStoreBackupRestoreCallbackTest() {
// RelationalStore backup function test
// RelationalStore backup function test
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
async
(
err
,
data
)
=>
{
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
async
(
err
,
data
)
=>
{
if
(
err
!=
null
){
if
(
err
!=
null
)
{
console
.
info
(
TAG
+
'
backup err ttt:
'
+
err
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
else
{
}
else
{
try
{
try
{
...
@@ -146,7 +147,6 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -146,7 +147,6 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
}
}
}
// RelationalStore before restored, delete data
// RelationalStore before restored, delete data
let
deleteData
=
new
data_Rdb
.
RdbPredicates
(
"
backupTest
"
)
let
deleteData
=
new
data_Rdb
.
RdbPredicates
(
"
backupTest
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
...
@@ -159,7 +159,7 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -159,7 +159,7 @@ export default function relationalStoreBackupRestoreCallbackTest() {
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
catch
(
err
)
{
}
catch
(
err
)
{
expect
(
true
).
assertTrue
(
)
console
.
info
(
TAG
+
"
restore1 done
"
)
}
}
try
{
try
{
...
@@ -259,7 +259,7 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -259,7 +259,7 @@ export default function relationalStoreBackupRestoreCallbackTest() {
it
(
'
RdbBackupRestoreCallbackTest_0500
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreCallbackTest_0500
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 start *************
"
)
// R
elationalStore
restore function test, backup file
// R
DB
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
()
expect
(
false
).
assertTrue
()
...
@@ -270,19 +270,15 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -270,19 +270,15 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
catch
(
err
){
}
catch
(
err
){
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
}
}
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_NAME
).
then
(()
=>
{
data_Rdb
.
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
+
'
RdbBackupRestoreCallbackTest_0500 deleteRdbStore done
'
)
expect
(
true
).
assertTrue
();
}
}
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
if
(
err
!=
null
){
console
.
info
(
`
${
TAG
}
Backup database second failed, error: message:
${
err
.
message
}
`
)
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 second success
'
)
console
.
info
(
TAG
+
'
Backup database second success
'
)
...
@@ -290,13 +286,13 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -290,13 +286,13 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
catch
(
err
){
}
catch
(
err
){
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
}
}
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
}
}
})
})
})
})
}
}
})
})
})
})
/**
/**
...
@@ -309,23 +305,17 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -309,23 +305,17 @@ export default function relationalStoreBackupRestoreCallbackTest() {
// Backup file is specified to database name
// Backup file is specified to database name
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
!=
null
).
assertTrue
()
expect
(
true
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup1 done
"
)
}
else
{
expect
(
false
).
assertTrue
()
}
})
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
!=
null
).
assertTrue
()
expect
(
true
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup2 done
"
)
}
else
{
expect
(
false
).
assertTrue
()
}
})
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0600 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0600 end *************
"
)
})
})
})
})
/**
/**
* @tc.name RelationalStore BackupRestore test
* @tc.name RelationalStore BackupRestore test
...
@@ -335,27 +325,25 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -335,27 +325,25 @@ export default function relationalStoreBackupRestoreCallbackTest() {
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 *************
"
)
let
DATABASE_BACKUP_TEST_NAME
=
"
BackupTest.db
"
let
DATABASE_BACKUP_TEST_NAME
=
"
BackupTest.db
"
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
async
(
err
,
data
)
=>
{
if
(
err
!=
null
)
{
if
(
err
!=
null
)
{
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
else
{
}
else
{
expect
(
true
).
assertTrue
(
)
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 backup done
"
)
}
}
})
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
,
()
=>
{
await
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
).
then
(()
=>
{
try
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_TEST_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_TEST_NAME
)
}
catch
(
err
)
{
}
catch
(
err
)
{
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 deleteRdbStore done
"
)
}
}
})
RdbStore
.
restore
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
RdbStore
.
restore
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
err
!=
null
).
assertTrue
()
expect
(
true
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 restore err
"
+
err
.
code
)
}
})
done
();
done
();
})
})
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 end *************
"
)
})
})
...
@@ -394,12 +382,11 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -394,12 +382,11 @@ export default function relationalStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
})
ReStoreCallbackTest
([
DATABASE_BACKUP_NAME
])
ReStoreCallbackTest
([
DATABASE_BACKUP_NAME
])
done
();
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1000 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1000 end *************
"
)
})
})
/**
/**
* @tc.name RelationalStore BackupRestore test
* @tc.name RelationalStore BackupRestore test
* @tc.number SUB_DDM_RelationalStore_JS_RdbBackupRestoreCallbackTest_1100
* @tc.number SUB_DDM_RelationalStore_JS_RdbBackupRestoreCallbackTest_1100
...
@@ -411,9 +398,9 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -411,9 +398,9 @@ export default function relationalStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
})
ReStoreCallbackTest
()
ReStoreCallbackTest
()
done
();
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1100 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1100 end *************
"
)
})
})
...
@@ -428,9 +415,9 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -428,9 +415,9 @@ export default function relationalStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
})
BackupCallbackTest
(
DATABASE_BACKUP_NAME
)
BackupCallbackTest
(
DATABASE_BACKUP_NAME
)
done
();
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1200 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1200 end *************
"
)
})
})
...
@@ -453,10 +440,10 @@ export default function relationalStoreBackupRestoreCallbackTest() {
...
@@ -453,10 +440,10 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
}
})
})
}
}
})
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1300 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1300 end *************
"
)
})
})
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
)
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
)
})
})
}
}
\ No newline at end of file
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreBackupRestoreWithFAContextJsunit.test.js
浏览文件 @
09888285
...
@@ -131,8 +131,8 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -131,8 +131,8 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0010
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0010 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0010 start *************
"
)
// R
elationalStore
backup function test
// R
DB
backup function test
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
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
)
...
@@ -140,31 +140,29 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -140,31 +140,29 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
"
RdbBackupRestoreTest_0010 backup success
"
)
console
.
info
(
"
RdbBackupRestoreTest_0010 backup success
"
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
// R
elationalStore
before restored, delete data
// R
DB
before restored, delete data
let
deleteData
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
)
let
deleteData
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
await
RdbStore
.
delete
(
deleteData
)
await
RdbStore
.
delete
(
deleteData
)
// RelationalStore
restore function test
// RDB
restore function test
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
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
"
)
console
.
info
(
"
RdbBackupRestoreTest_0010 restore success
"
)
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
()
}
}
// R
elationalStore
after restored, data query test
// R
DB
after restored, data query test
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
)
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
)
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
RdbStore
.
query
(
predicates
).
then
((
resultSet
)
=>
{
let
resultSet
=
await
RdbStore
.
query
(
predicates
)
try
{
try
{
console
.
info
(
TAG
+
"
After restore resultSet query done
"
)
console
.
info
(
TAG
+
"
After restore resultSet query done
"
)
resultSet
.
goToFirstRow
();
resultSet
.
goToFirstRow
();
...
@@ -183,24 +181,13 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -183,24 +181,13 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0010 accessSync err4:
'
+
err
)
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0010 accessSync err4:
'
+
err
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
resultSet
=
null
resultSet
.
close
()
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 RelationalStore Backup test
* @tc.name RelationalStore Backup test
* @tc.number SUB_DDM_RelationalStore_JS_RdbBackupRestoreTest_0020
* @tc.number SUB_DDM_RelationalStore_JS_RdbBackupRestoreTest_0020
...
@@ -281,7 +268,6 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -281,7 +268,6 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
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
();
}
}
})
})
}).
then
(()
=>
{
}).
then
(()
=>
{
...
@@ -293,9 +279,9 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -293,9 +279,9 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
'
error3
'
+
err
)
console
.
info
(
TAG
+
'
error3
'
+
err
)
expect
(
false
).
assertTrue
()
expect
(
false
).
assertTrue
()
}
}
done
();
})
})
})
})
done
()
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0050 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0050 end *************
"
)
})
})
...
@@ -312,7 +298,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -312,7 +298,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
expect
(
false
).
assertTrue
()
;
expect
(
false
).
assertTrue
()
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Backup database error
"
);
console
.
info
(
TAG
+
"
Backup database error
"
);
expect
(
true
).
assertTrue
()
;
expect
(
err
!=
null
).
assertTrue
()
;
done
();
done
();
})
})
})
})
...
@@ -328,11 +314,11 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -328,11 +314,11 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
try
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
){
}
catch
(
err
){
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
'
deleteRdbStore done
'
)
}
}
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
.
code
);
expect
(
true
).
assertTrue
();
expect
(
err
!=
null
).
assertTrue
();
})
})
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 end *************
"
)
...
@@ -370,7 +356,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -370,7 +356,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
([
DATABASE_BACKUP_NAME
])
await
ReStoreTest
([
DATABASE_BACKUP_NAME
])
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 end *************
"
)
})
})
...
@@ -383,7 +369,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -383,7 +369,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0110
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0110
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
()
await
ReStoreTest
()
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 end *************
"
)
})
})
...
@@ -396,7 +382,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -396,7 +382,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0120
'
,
0
,
async
function
(
done
)
{
it
(
'
RdbBackupRestoreTest_0120
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
BackupTest
(
DATABASE_BACKUP_NAME
)
await
BackupTest
(
DATABASE_BACKUP_NAME
)
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 end *************
"
)
})
})
...
@@ -410,7 +396,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
...
@@ -410,7 +396,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 start *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
ReStoreTest
(
DATABASE_BACKUP_NAME
)
await
ReStoreTest
(
DATABASE_BACKUP_NAME
)
done
();
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 end *************
"
)
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 end *************
"
)
})
})
...
...
distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/relationalStoreEtsunit.test.ets
浏览文件 @
09888285
...
@@ -149,13 +149,11 @@ describe('relationalStoreTest', function () {
...
@@ -149,13 +149,11 @@ describe('relationalStoreTest', function () {
} catch (err) {
} catch (err) {
expect(null).assertFail();
expect(null).assertFail();
}
}
await dataRdb.deleteRdbStore(context,"secure.db");
done();
}).catch((err) => {
}).catch((err) => {
expect(null).assertFail();
expect(null).assertFail();
})
})
await storePromise
storePromise = null
await dataRdb.deleteRdbStore(context,"secure.db");
done();
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTORE_PROMISE_0400 end *************");
console.log(TAG + "************* SUB_DDM_RELATIONALETS_GETRDBSTORE_PROMISE_0400 end *************");
})
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录