Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e215c5c1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e215c5c1
编写于
2月 24, 2023
作者:
Y
yanglifeng1217
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<modified>
Signed-off-by:
N
yanglifeng1217
<
yanglifeng5@huawei.com
>
上级
358dd58f
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
256 addition
and
306 deletion
+256
-306
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
+40
-50
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
+80
-93
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
+18
-20
未找到文件。
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/List.test.js
浏览文件 @
e215c5c1
/*
* Copyright (c) 2021-202
3
Huawei Device Co., Ltd.
* Copyright (c) 2021-202
2
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
rdbStoreBackupRestoreCallbackTest
from
'
./RdbstoreBackupRestoreCallbackJsunit.test.js
'
import
rdbStoreBackupRestoreWithFAContextTest
from
'
./RdbstoreBackupRestoreWithFAContextJsunit.test.js
'
import
rdbStoreDeleteTest
from
'
./RdbstoreDeleteJsunit.test.js
'
import
rdbStoreDistributedTest
from
'
./RdbStoreDistributedJsunit.test.js
'
import
rdbstoreInsertTest
from
'
./RdbstoreInsertJsunit.test.js
'
...
...
@@ -27,9 +26,9 @@ import rdbStoreUpdateTest from './RdbstoreUpdateJsunit.test.js'
import
rdbstoreQueryTest
from
'
./RdbstoreQuery.test.js
'
import
rdbStoreEncryptionTest
from
'
./RdbstoreEncryptionJsunit.test.js
'
import
rdbStorePredicatesComplexFiledTest
from
'
./RdbstorePredicatesComplexFiledJsunit.test.js
'
import
rdbStoreBackupRestoreWithFAContextTest
from
'
./RdbstoreBackupRestoreWithFAContextJsunit.test.js
'
import
rdbStoreBackupRestoreCallbackTest
from
'
./RdbstoreBackupRestoreCallbackJsunit.test.js
'
export
default
function
testsuite
()
{
rdbStoreBackupRestoreCallbackTest
()
rdbStoreBackupRestoreWithFAContextTest
()
rdbStoreDeleteTest
()
rdbStoreDistributedTest
()
rdbstoreInsertTest
()
...
...
@@ -43,4 +42,6 @@ export default function testsuite() {
rdbstoreQueryTest
()
rdbStoreEncryptionTest
()
rdbStorePredicatesComplexFiledTest
()
rdbStoreBackupRestoreWithFAContextTest
()
rdbStoreBackupRestoreCallbackTest
()
}
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreBackupRestoreCallbackJsunit.test.js
浏览文件 @
e215c5c1
...
...
@@ -146,7 +146,6 @@ export default function rdbStoreBackupRestoreCallbackTest() {
}
}
// RDB before restored, delete data
let
deleteData
=
new
dataRdb
.
RdbPredicates
(
"
backupTest
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
...
...
@@ -159,7 +158,7 @@ export default function rdbStoreBackupRestoreCallbackTest() {
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
expect
(
false
).
assertTrue
()
}
catch
(
err
)
{
expect
(
true
).
assertTrue
(
)
console
.
info
(
TAG
+
"
rdb restore1 done
"
)
}
try
{
...
...
@@ -275,14 +274,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
){
console
.
info
(
TAG
+
'
error2
'
+
err
)
expect
(
true
).
assertTrue
();
}
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
console
.
info
(
`
${
TAG
}
Backup database second failed, error: message:
${
err
.
message
}
`
)
expect
(
true
).
assertTrue
()
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
console
.
info
(
`
${
TAG
}
Backup database second failed`
)
}
else
{
try
{
console
.
info
(
TAG
+
'
Backup database second success
'
)
...
...
@@ -291,12 +286,12 @@ export default function rdbStoreBackupRestoreCallbackTest() {
expect
(
false
).
assertTrue
();
}
}
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
})
})
}
})
})
/**
...
...
@@ -309,23 +304,17 @@ export default function rdbStoreBackupRestoreCallbackTest() {
// Backup file is specified to database name
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
true
).
assertTrue
()
}
else
{
expect
(
false
).
assertTrue
()
}
})
expect
(
err
!=
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup1 done
"
)
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
true
).
assertTrue
()
}
else
{
expect
(
false
).
assertTrue
()
}
})
expect
(
err
!=
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup2 done
"
)
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0600 end *************
"
)
})
})
})
/**
* @tc.name RDB BackupRestore test
...
...
@@ -335,27 +324,23 @@ export default function rdbStoreBackupRestoreCallbackTest() {
it
(
'
RdbBackupRestoreCallbackTest_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 start *************
"
)
let
DATABASE_BACKUP_TEST_NAME
=
"
BackupTest.db
"
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
else
{
expect
(
true
).
assertTrue
()
}
})
await
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
).
then
(()
=>
{
try
{
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
async
(
err
,
data
)
=>
{
expect
(
err
==
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 backup done
"
)
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
,
()
=>
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_TEST_NAME
)
}
catch
(
err
)
{
expect
(
true
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 deleteRdbStore done
"
)
}
})
RdbStore
.
restore
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
true
).
assertTrue
()
}
})
expect
(
err
!=
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 restore done
"
)
done
();
})
})
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 end *************
"
)
})
...
...
@@ -394,9 +379,11 @@ export default function rdbStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
})
ReStoreCallbackTest
([
DATABASE_BACKUP_NAME
])
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1000 end *************
"
)
})
...
...
@@ -411,9 +398,11 @@ export default function rdbStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
})
ReStoreCallbackTest
()
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1100 end *************
"
)
})
...
...
@@ -428,9 +417,10 @@ export default function rdbStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
})
BackupCallbackTest
(
DATABASE_BACKUP_NAME
)
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1200 end *************
"
)
})
...
...
distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreBackupRestoreWithFAContextJsunit.test.js
浏览文件 @
e215c5c1
...
...
@@ -12,14 +12,14 @@
* See the License for the specific language governing permissions and
* 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
abilityFeatureAbility
from
'
@ohos.ability.featureAbility
'
import
fileio
from
'
@ohos.fileio
'
const
TAG
=
"
[RDB_JSKITS_TEST]
"
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/
"
var
RdbStore
var
context
...
...
@@ -72,7 +72,7 @@ async function BackupTest(backupName) {
expect
(
true
).
assertTrue
()
})
await
promiseRestore
}
catch
(
errInfo
)
{
}
catch
(
errInfo
)
{
console
.
info
(
TAG
+
"
BackupTest error:
"
+
errInfo
)
expect
(
true
).
assertTrue
()
}
...
...
@@ -90,7 +90,7 @@ async function ReStoreTest(restoreName) {
expect
(
true
).
assertTrue
()
})
await
promiseRestore
}
catch
(
errInfo
)
{
}
catch
(
errInfo
)
{
console
.
info
(
TAG
+
"
ReStoreTest error:
"
+
errInfo
)
expect
(
true
).
assertTrue
()
}
...
...
@@ -99,7 +99,7 @@ async function ReStoreTest(restoreName) {
}
export
default
function
rdbStoreBackupRestorePromiseTest
()
{
describe
(
'
rdbStoreBackupRestorePromiseTest
'
,
function
()
{
describe
(
'
rdbStoreBackupRestorePromiseTest
'
,
function
()
{
beforeAll
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeAll
'
)
})
...
...
@@ -132,7 +132,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0010 start *************
"
)
// RDB backup function test
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
STORE_CONFIG
.
name
)
...
...
@@ -146,13 +146,12 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
await
RdbStore
.
delete
(
deleteData
)
// RDB restore function test
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
expect
(
false
).
assertTrue
()
}
catch
(
err
)
{
console
.
info
(
"
RdbBackupRestoreTest_0010 restore success
"
)
expect
(
true
).
assertTrue
()
}
try
{
...
...
@@ -164,7 +163,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
// RDB after restored, data query test
let
predicates
=
new
dataRdb
.
RdbPredicates
(
"
test
"
)
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
RdbStore
.
query
(
predicates
).
then
((
resultSet
)
=>
{
let
resultSet
=
await
RdbStore
.
query
(
predicates
)
try
{
console
.
info
(
TAG
+
"
After restore resultSet query done
"
)
resultSet
.
goToFirstRow
();
...
...
@@ -183,24 +182,13 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0010 accessSync err4:
'
+
err
)
expect
(
false
).
assertTrue
()
}
resultSet
=
null
resultSet
.
close
()
RdbStore
=
null
done
()
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.number SUB_DDM_RDB_JS_RdbBackupRestoreTest_0020
...
...
@@ -269,33 +257,32 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
// RDB restore function test, backup file
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(()
=>
{
try
{
try
{
console
.
info
(
TAG
+
'
Backup database success
'
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
)
{
}
catch
(
err
)
{
expect
(
false
).
assertTrue
();
}
}).
then
(()
=>
{
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_NAME
).
then
(()
=>
{
try
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
){
console
.
info
(
TAG
+
'
error2
'
+
err
)
expect
(
true
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0050 deleteRdbStore done
'
)
}
})
}).
then
(()
=>
{
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(()
=>
{
try
{
try
{
console
.
info
(
TAG
+
'
Backup database success
'
)
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
info
(
TAG
+
'
error3
'
+
err
)
expect
(
false
).
assertTrue
()
}
done
()
})
})
done
()
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0050 end *************
"
)
})
...
...
@@ -308,11 +295,11 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0060 start *************
"
)
// Backup file is specified to database name
RdbStore
.
backup
(
STORE_CONFIG
.
name
).
then
(()
=>
{
console
.
info
(
TAG
+
'
Backup database finish
'
);
expect
(
false
).
assertTrue
()
;
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0060 Backup database err
'
);
expect
(
false
).
assertTrue
();
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Backup database error
"
);
expect
(
true
).
assertTrue
()
;
console
.
info
(
TAG
+
"
RdbBackupRestoreTest_0060 Backup database done
"
);
expect
(
err
!=
null
).
assertTrue
()
;
done
();
})
})
...
...
@@ -325,14 +312,14 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
dataRdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_NAME
)
try
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
)
{
expect
(
true
).
assertTrue
(
);
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
RdbBackupRestoreTest_0070 deleteRdbStore done
"
);
}
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
'
Restore
fail:
'
+
err
)
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
'
Restore
'
)
expect
(
err
!=
null
).
assertTrue
();
})
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 end *************
"
)
...
...
@@ -370,7 +357,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
([
DATABASE_BACKUP_NAME
])
await
ReStoreTest
([
DATABASE_BACKUP_NAME
])
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 end *************
"
)
})
...
...
@@ -383,7 +370,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0110
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
()
await
ReStoreTest
()
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 end *************
"
)
})
...
...
@@ -396,7 +383,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0120
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
BackupTest
(
DATABASE_BACKUP_NAME
)
await
BackupTest
(
DATABASE_BACKUP_NAME
)
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 end *************
"
)
})
...
...
@@ -410,7 +397,7 @@ describe('rdbStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
ReStoreTest
(
DATABASE_BACKUP_NAME
)
await
ReStoreTest
(
DATABASE_BACKUP_NAME
)
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 end *************
"
)
})
...
...
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/List.test.js
浏览文件 @
e215c5c1
...
...
@@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
relationalStoreBackupRestoreCallbackTest
from
'
./RelationalStoreBackupRestoreCallbackJsunit.test.js
'
import
relationalStoreBackupRestoreWithFAContextTest
from
'
./RelationalStoreBackupRestoreWithFAContextJsunit.test.js
'
import
relationalStoreDeleteTest
from
'
./RelationalStoreDeleteJsunit.test.js
'
import
relationalStoreDistributedTest
from
'
./RelationalStoreDistributedJsunit.test.js
'
import
relationalStoreInsertTest
from
'
./RelationalStoreInsertJsunit.test.js
'
...
...
@@ -27,9 +26,9 @@ import relationalStoreUpdateTest from './RelationalStoreUpdateJsunit.test.js'
import
relationalStoreQueryTest
from
'
./RelationalStoreQuery.test.js
'
import
relationalStoreEncryptionTest
from
'
./RelationalStoreEncryptionJsunit.test.js
'
import
relationalStorePredicatesComplexFiledTest
from
'
./RelationalStorePredicatesComplexFiledJsunit.test.js
'
import
relationalStoreBackupRestoreWithFAContextTest
from
'
./RelationalStoreBackupRestoreWithFAContextJsunit.test.js
'
import
relationalStoreBackupRestoreCallbackTest
from
'
./RelationalStoreBackupRestoreCallbackJsunit.test.js
'
export
default
function
testsuite
()
{
relationalStoreBackupRestoreCallbackTest
()
relationalStoreBackupRestoreWithFAContextTest
()
relationalStoreDeleteTest
()
relationalStoreDistributedTest
()
relationalStoreInsertTest
()
...
...
@@ -43,4 +42,6 @@ export default function testsuite() {
relationalStoreQueryTest
()
relationalStoreEncryptionTest
()
relationalStorePredicatesComplexFiledTest
()
relationalStoreBackupRestoreWithFAContextTest
()
relationalStoreBackupRestoreCallbackTest
()
}
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreBackupRestoreCallbackJsunit.test.js
浏览文件 @
e215c5c1
...
...
@@ -19,7 +19,7 @@ import fileio from '@ohos.fileio'
const
TAG
=
"
[RelationalStore_JSKITS_TEST]
"
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/
"
var
RdbStore
var
context
=
ability_featureAbility
.
getContext
()
...
...
@@ -135,7 +135,8 @@ export default function relationalStoreBackupRestoreCallbackTest() {
// RelationalStore backup function test
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
()
}
else
{
try
{
...
...
@@ -146,7 +147,6 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
}
// RelationalStore before restored, delete data
let
deleteData
=
new
data_Rdb
.
RdbPredicates
(
"
backupTest
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
...
...
@@ -159,7 +159,7 @@ export default function relationalStoreBackupRestoreCallbackTest() {
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
expect
(
false
).
assertTrue
()
}
catch
(
err
)
{
expect
(
true
).
assertTrue
(
)
console
.
info
(
TAG
+
"
restore1 done
"
)
}
try
{
...
...
@@ -259,7 +259,7 @@ export default function relationalStoreBackupRestoreCallbackTest() {
it
(
'
RdbBackupRestoreCallbackTest_0500
'
,
0
,
async
function
(
done
)
{
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
)
=>
{
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
...
...
@@ -270,19 +270,15 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
catch
(
err
){
expect
(
false
).
assertTrue
();
}
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_NAME
).
then
(()
=>
{
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_NAME
).
then
(()
=>
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
){
console
.
info
(
TAG
+
'
error2
'
+
err
)
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
'
RdbBackupRestoreCallbackTest_0500 deleteRdbStore done
'
)
}
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
console
.
info
(
`
${
TAG
}
Backup database second failed, error: message:
${
err
.
message
}
`
)
expect
(
true
).
assertTrue
()
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
}
else
{
try
{
console
.
info
(
TAG
+
'
Backup database second success
'
)
...
...
@@ -290,13 +286,13 @@ export default function relationalStoreBackupRestoreCallbackTest() {
}
catch
(
err
){
expect
(
false
).
assertTrue
();
}
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0500 end *************
"
)
}
})
})
}
})
})
/**
...
...
@@ -309,23 +305,17 @@ export default function relationalStoreBackupRestoreCallbackTest() {
// Backup file is specified to database name
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
true
).
assertTrue
()
}
else
{
expect
(
false
).
assertTrue
()
}
})
expect
(
err
!=
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup1 done
"
)
RdbStore
.
backup
(
STORE_CONFIG
.
name
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
true
).
assertTrue
()
}
else
{
expect
(
false
).
assertTrue
()
}
})
expect
(
err
!=
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0600 backup2 done
"
)
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0600 end *************
"
)
})
})
})
/**
* @tc.name RelationalStore BackupRestore test
...
...
@@ -335,27 +325,25 @@ export default function relationalStoreBackupRestoreCallbackTest() {
it
(
'
RdbBackupRestoreCallbackTest_0700
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 start *************
"
)
let
DATABASE_BACKUP_TEST_NAME
=
"
BackupTest.db
"
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
)
{
RdbStore
.
backup
(
DATABASE_BACKUP_TEST_NAME
,
async
(
err
,
data
)
=>
{
if
(
err
!=
null
)
{
expect
(
false
).
assertTrue
()
}
else
{
expect
(
true
).
assertTrue
(
)
}
else
{
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 backup done
"
)
}
})
await
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
).
then
(()
=>
{
try
{
data_Rdb
.
deleteRdbStore
(
context
,
DATABASE_BACKUP_TEST_NAME
,
()
=>
{
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_TEST_NAME
)
}
catch
(
err
)
{
expect
(
true
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 deleteRdbStore done
"
)
}
})
RdbStore
.
restore
(
DATABASE_BACKUP_TEST_NAME
,
(
err
,
data
)
=>
{
if
(
err
!=
null
){
expect
(
true
).
assertTrue
()
}
})
expect
(
err
!=
null
).
assertTrue
()
console
.
info
(
TAG
+
"
RdbBackupRestoreCallbackTest_0700 restore err
"
+
err
.
code
)
done
();
})
})
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_0700 end *************
"
)
})
...
...
@@ -394,12 +382,11 @@ export default function relationalStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
})
ReStoreCallbackTest
([
DATABASE_BACKUP_NAME
])
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1000 end *************
"
)
})
/**
* @tc.name RelationalStore BackupRestore test
* @tc.number SUB_DDM_RelationalStore_JS_RdbBackupRestoreCallbackTest_1100
...
...
@@ -411,9 +398,9 @@ export default function relationalStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
})
ReStoreCallbackTest
()
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1100 end *************
"
)
})
...
...
@@ -428,9 +415,9 @@ export default function relationalStoreBackupRestoreCallbackTest() {
if
(
err
!=
null
){
expect
(
false
).
assertTrue
()
}
})
BackupCallbackTest
(
DATABASE_BACKUP_NAME
)
done
();
})
console
.
info
(
TAG
+
"
************* RdbBackupRestoreCallbackTest_1200 end *************
"
)
})
...
...
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreBackupRestoreWithFAContextJsunit.test.js
浏览文件 @
e215c5c1
...
...
@@ -131,8 +131,8 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0010
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0010 start *************
"
)
// R
elationalStore
backup function test
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
// R
DB
backup function test
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
fileio
.
accessSync
(
DATABASE_DIR
+
STORE_CONFIG
.
name
)
...
...
@@ -140,31 +140,29 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
"
RdbBackupRestoreTest_0010 backup success
"
)
expect
(
false
).
assertTrue
()
}
// R
elationalStore
before restored, delete data
// R
DB
before restored, delete data
let
deleteData
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
)
deleteData
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
await
RdbStore
.
delete
(
deleteData
)
// RelationalStore
restore function test
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
).
then
(
async
()
=>
{
// RDB
restore function test
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
expect
(
false
).
assertTrue
()
}
catch
(
err
)
{
console
.
info
(
"
RdbBackupRestoreTest_0010 restore success
"
)
expect
(
true
).
assertTrue
()
}
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
STORE_CONFIG
.
name
)
}
catch
(
err
)
{
console
.
info
(
"
RdbBackupRestoreTest_0010 restore success2
"
)
expect
(
false
).
assertTrue
()
}
// R
elationalStore
after restored, data query test
// R
DB
after restored, data query test
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
)
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
RdbStore
.
query
(
predicates
).
then
((
resultSet
)
=>
{
let
resultSet
=
await
RdbStore
.
query
(
predicates
)
try
{
console
.
info
(
TAG
+
"
After restore resultSet query done
"
)
resultSet
.
goToFirstRow
();
...
...
@@ -183,24 +181,13 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
'
RdbBackupRestoreTest_0010 accessSync err4:
'
+
err
)
expect
(
false
).
assertTrue
()
}
resultSet
=
null
resultSet
.
close
()
RdbStore
=
null
done
()
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.number SUB_DDM_RelationalStore_JS_RdbBackupRestoreTest_0020
...
...
@@ -281,7 +268,6 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
){
console
.
info
(
TAG
+
'
error2
'
+
err
)
expect
(
true
).
assertTrue
();
}
})
}).
then
(()
=>
{
...
...
@@ -293,9 +279,9 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
'
error3
'
+
err
)
expect
(
false
).
assertTrue
()
}
done
();
})
})
done
()
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0050 end *************
"
)
})
...
...
@@ -312,7 +298,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
expect
(
false
).
assertTrue
()
;
}).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
"
Backup database error
"
);
expect
(
true
).
assertTrue
()
;
expect
(
err
!=
null
).
assertTrue
()
;
done
();
})
})
...
...
@@ -328,11 +314,11 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
try
{
fileio
.
accessSync
(
DATABASE_DIR
+
DATABASE_BACKUP_NAME
)
}
catch
(
err
){
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
'
deleteRdbStore done
'
)
}
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
).
catch
((
err
)
=>
{
console
.
info
(
TAG
+
'
Restore fail:
'
+
err
)
expect
(
true
).
assertTrue
();
console
.
info
(
TAG
+
'
Restore fail:
'
+
err
.
code
);
expect
(
err
!=
null
).
assertTrue
();
})
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0070 end *************
"
)
...
...
@@ -370,7 +356,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0100
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
([
DATABASE_BACKUP_NAME
])
await
ReStoreTest
([
DATABASE_BACKUP_NAME
])
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0100 end *************
"
)
})
...
...
@@ -383,7 +369,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0110
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
ReStoreTest
()
await
ReStoreTest
()
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0110 end *************
"
)
})
...
...
@@ -396,7 +382,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
it
(
'
RdbBackupRestoreTest_0120
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
BackupTest
(
DATABASE_BACKUP_NAME
)
await
BackupTest
(
DATABASE_BACKUP_NAME
)
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0120 end *************
"
)
})
...
...
@@ -410,7 +396,7 @@ describe('relationalStoreBackupRestorePromiseTest', function () {
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 start *************
"
)
await
RdbStore
.
backup
(
DATABASE_BACKUP_NAME
)
await
RdbStore
.
restore
(
DATABASE_BACKUP_NAME
)
ReStoreTest
(
DATABASE_BACKUP_NAME
)
await
ReStoreTest
(
DATABASE_BACKUP_NAME
)
done
();
console
.
info
(
TAG
+
"
************* RdbBackupRestoreTest_0130 end *************
"
)
})
...
...
distributeddatamgr/relationalStoretest/relationalStoreStagetest/entry/src/main/ets/test/relationalStoreEtsunit.test.ets
浏览文件 @
e215c5c1
/*
* Copyright (C) 2022
-2023
Huawei Device Co., Ltd.
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -149,13 +149,11 @@ describe('relationalStoreTest', function () {
} catch (err) {
expect(null).assertFail();
}
await dataRdb.deleteRdbStore(context,"secure.db");
done();
}).catch((err) => {
expect(null).assertFail();
})
await storePromise
storePromise = null
await dataRdb.deleteRdbStore(context,"secure.db");
done();
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录