Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e34a9e96
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,发现更多精彩内容 >>
提交
e34a9e96
编写于
11月 16, 2022
作者:
L
liuhaonan2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<liuhaonan8@huawei.com>
Signed-off-by:
N
liuhaonan2
<
liuhaonan8@huawei.com
>
上级
6375b532
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
69 deletion
+65
-69
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js
...st/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js
+47
-50
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js
...est/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js
+12
-12
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RdbstoreQuery.test.js
...nalStoreJstest/hap/src/main/js/test/RdbstoreQuery.test.js
+6
-7
未找到文件。
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js
浏览文件 @
e34a9e96
...
...
@@ -13,19 +13,63 @@
* 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
'
;
let
context
=
abilityFeatureAbility
.
getContext
();
var
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS employee (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER)
"
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS product (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
price REAL,
"
+
"
vendor INTEGER,
"
+
"
describe TEXT)
"
const
TAG
=
"
[RDB_JSKITS_TEST_Distributed]
"
const
STORE_NAME
=
"
distributed_rdb.db
"
var
rdbStore
=
undefined
;
const
config
=
{
"
name
"
:
STORE_NAME
,
}
async
function
executeSql1
()
{
let
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS employee (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER)
"
try
{
await
rdbStore
.
executeSql
(
sqlStatement
,
null
)
console
.
info
(
TAG
+
"
create table employee success
"
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
create table employee failed
"
)
expect
(
null
).
assertFail
()
}
}
async
function
executeSql2
()
{
let
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS product (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
price REAL,
"
+
"
vendor INTEGER,
"
+
"
describe TEXT)
"
try
{
await
rdbStore
.
executeSql
(
sqlStatement
,
null
)
console
.
info
(
TAG
+
"
create table product success
"
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
create table product failed
"
)
expect
(
null
).
assertFail
()
}
}
export
default
function
rdbStoreDistributedTest
()
{
describe
(
'
rdbStoreDistributedTest
'
,
function
()
{
beforeAll
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeAll
'
)
rdbStore
=
await
dataRdb
.
getRdbStore
(
config
,
1
);
console
.
info
(
TAG
+
"
create rdb store success
"
)
await
executeSql1
()
await
executeSql2
()
})
beforeEach
(
async
function
()
{
...
...
@@ -43,53 +87,6 @@ describe('rdbStoreDistributedTest', function () {
console
.
info
(
TAG
+
"
*************Unit Test Begin*************
"
);
/**
* @tc.name rdb open test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_001
* @tc.desc rdb open test
*/
it
(
'
testRdbStoreDistributed0001
'
,
0
,
async
function
(
done
)
{
console
.
info
(
TAG
+
"
************* testRdbStoreDistributed001 start *************
"
);
const
config
=
{
"
name
"
:
STORE_NAME
,
}
try
{
rdbStore
=
await
dataRdb
.
getRdbStore
(
config
,
1
);
console
.
info
(
TAG
+
"
create rdb store success
"
)
expect
(
rdbStore
).
assertEqual
(
rdbStore
)
let
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS employee (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
age INTEGER)
"
try
{
await
rdbStore
.
executeSql
(
sqlStatement
,
null
)
console
.
info
(
TAG
+
"
create table employee success
"
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
create table employee failed
"
)
expect
(
null
).
assertFail
()
}
sqlStatement
=
"
CREATE TABLE IF NOT EXISTS product (
"
+
"
id INTEGER PRIMARY KEY AUTOINCREMENT,
"
+
"
name TEXT NOT NULL,
"
+
"
price REAL,
"
+
"
vendor INTEGER,
"
+
"
describe TEXT)
"
try
{
await
rdbStore
.
executeSql
(
sqlStatement
,
null
)
console
.
info
(
TAG
+
"
create table product success
"
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
create table product failed
"
)
expect
(
null
).
assertFail
()
}
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
create rdb store failed
"
)
expect
(
null
).
assertFail
()
}
done
()
console
.
info
(
TAG
+
"
************* testRdbStoreDistributed001 end *************
"
);
})
/**
* @tc.name set_distributed_table_none_table
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_002
...
...
@@ -163,7 +160,7 @@ describe('rdbStoreDistributedTest', function () {
console
.
info
(
TAG
+
"
insert one record success
"
+
rowId
)
expect
(
1
).
assertEqual
(
rowId
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
insert one record failed
"
);
console
.
info
(
TAG
+
"
insert one record failed
"
+
err
);
expect
(
null
).
assertFail
();
}
done
()
...
...
@@ -189,7 +186,7 @@ describe('rdbStoreDistributedTest', function () {
console
.
info
(
TAG
+
"
update one record success
"
+
rowId
)
expect
(
1
).
assertEqual
(
rowId
)
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
update one record failed
"
);
console
.
info
(
TAG
+
"
update one record failed
"
+
err
);
expect
(
null
).
assertFail
();
}
}
catch
(
err
)
{
...
...
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js
浏览文件 @
e34a9e96
...
...
@@ -102,23 +102,23 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB create encrypt db test
*/
it
(
'
RdbEncryptTest_0010
'
,
0
,
async
function
(
done
)
{
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0010 start *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0010 start *************
"
)
context
=
ability_featureAbility
.
getContext
()
let
storePromise
=
data_rdb
.
getRdbStore
(
context
,
STORE_CONFIG_ENCRYPT
,
1
);
storePromise
.
then
(
async
(
store
)
=>
{
try
{
await
console
.
log
(
TAG
+
"
getRdbStore done:
"
+
store
);
console
.
log
(
TAG
+
"
getRdbStore done:
"
+
store
);
}
catch
(
err
)
{
expect
(
null
).
assertFail
();
}
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
})
await
storePromise
storePromise
storePromise
=
null
done
()
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0010 end *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0010 end *************
"
)
})
/**
...
...
@@ -127,23 +127,23 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB create unencrypted db test
*/
it
(
'
RdbEncryptTest_0020
'
,
0
,
async
function
(
done
)
{
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0020 start *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0020 start *************
"
)
context
=
ability_featureAbility
.
getContext
()
let
storePromise
=
data_rdb
.
getRdbStore
(
context
,
STORE_CONFIG_UNENCRYPT
,
1
);
storePromise
.
then
(
async
(
store
)
=>
{
try
{
await
console
.
log
(
TAG
+
"
getRdbStore done:
"
+
store
);
console
.
log
(
TAG
+
"
getRdbStore done:
"
+
store
);
}
catch
(
err
)
{
expect
(
null
).
assertFail
();
}
}).
catch
((
err
)
=>
{
expect
(
null
).
assertFail
();
})
await
storePromise
storePromise
storePromise
=
null
done
()
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0020 end *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0020 end *************
"
)
})
...
...
@@ -153,7 +153,7 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB Encrypt function test
*/
it
(
'
RdbEncryptTest_0030
'
,
0
,
async
function
(
done
)
{
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0030 start *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0030 start *************
"
)
context
=
ability_featureAbility
.
getContext
()
rdbStore
=
await
CreatRdbStore
(
context
,
STORE_CONFIG_ENCRYPT
)
let
predicates
=
new
data_rdb
.
RdbPredicates
(
"
test
"
)
...
...
@@ -174,7 +174,7 @@ describe('rdbEncryptTest', function () {
resultSet
=
null
rdbStore
=
null
done
()
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0030 end *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0030 end *************
"
)
})
/**
...
...
@@ -183,7 +183,7 @@ describe('rdbEncryptTest', function () {
* @tc.desc RDB Encrypt function test
*/
it
(
'
RdbEncryptTest_0040
'
,
0
,
async
function
(
done
)
{
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0040 start *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0040 start *************
"
)
context
=
ability_featureAbility
.
getContext
()
rdbStore
=
await
CreatRdbStore
(
context
,
STORE_CONFIG_ENCRYPT
)
rdbStore
=
null
...
...
@@ -191,7 +191,7 @@ describe('rdbEncryptTest', function () {
expect
(
rdbStore
).
assertNull
done
()
await
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0040 end *************
"
)
console
.
log
(
TAG
+
"
************* RdbEncryptTest_0040 end *************
"
)
})
console
.
log
(
TAG
+
"
*************Unit Test End*************
"
)
}
...
...
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RdbstoreQuery.test.js
浏览文件 @
e34a9e96
...
...
@@ -12,23 +12,22 @@
* 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
factory
from
'
@ohos.data.distributedData
'
import
abilityFeatureAbility
from
'
@ohos.ability.featureAbility
'
import
factory
from
'
@ohos.data.distributedData
'
;
import
abilityFeatureAbility
from
'
@ohos.ability.featureAbility
'
;
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)
"
const
DATABASE_DIR
=
"
/data/storage/el2/database/entry/rdb/
"
const
STORE_CONFIG
=
{
name
:
"
Query.db
"
,
}
const
TEST_BUNDLE_NAME
=
"
ohos.acts.relationalStorejstest
"
var
kvManager
=
null
;
var
kvStore
=
null
;
var
localDeviceId
=
null
;
var
kvManager
=
null
var
kvStore
=
null
var
localDeviceId
=
null
var
rdbStore
let
context
=
abilityFeatureAbility
.
getContext
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录