Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
60d512ed
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看板
未验证
提交
60d512ed
编写于
4月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3018 【Distributeddatamgr】【Master】用例同步 RdbstoreChangeEncryptKeyJsunit.test.js
Merge pull request !3018 from Maowen/master
上级
25ed21f2
655420de
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
176 addition
and
14 deletion
+176
-14
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/List.test.js
...ppdatamgrjstest/hap/src/main/js/default/test/List.test.js
+1
-0
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreChangeEncryptKeyJsunit.test.js
...in/js/default/test/RdbstoreChangeEncryptKeyJsunit.test.js
+164
-0
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstorePredicatesJoinJsunit.test.js
...main/js/default/test/RdbstorePredicatesJoinJsunit.test.js
+6
-9
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreTransactionJsunit.test.js
...rc/main/js/default/test/RdbstoreTransactionJsunit.test.js
+3
-3
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js
...c/main/js/default/test/DeviceKvStorePromiseJsunit.test.js
+2
-2
未找到文件。
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/List.test.js
浏览文件 @
60d512ed
...
@@ -27,5 +27,6 @@ require('./DataAbilityPredicatesJsunit.test.js')
...
@@ -27,5 +27,6 @@ require('./DataAbilityPredicatesJsunit.test.js')
require
(
'
./RdbstoreTransactionJsunit.test.js
'
)
require
(
'
./RdbstoreTransactionJsunit.test.js
'
)
require
(
'
./RdbstorePredicatesJoinJsunit.test.js
'
)
require
(
'
./RdbstorePredicatesJoinJsunit.test.js
'
)
require
(
'
./RdbStoreDistributedJsunit.test.js
'
)
require
(
'
./RdbStoreDistributedJsunit.test.js
'
)
require
(
'
./RdbstoreChangeEncryptKeyJsunit.test.js
'
)
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreChangeEncryptKeyJsunit.test.js
0 → 100644
浏览文件 @
60d512ed
// @ts-nocheck
/*
* Copyright (C) 2021 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
dataRdb
from
'
@ohos.data.rdb
'
;
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
STORE_CONFIG
=
{
name
:
"
EncryptNoKeyInsertTest.db
"
,
encryptKey
:
new
Uint8Array
([
1
,
2
,
3
])
}
const
STORE_CONFIG_NO_KEY
=
{
name
:
"
EncryptNoKeyInsertTest.db
"
}
var
i
=
1
;
var
rdbStore
=
undefined
;
describe
(
'
rdbStoreInsertTest
'
,
function
()
{
beforeAll
(
async
function
()
{
console
.
info
(
TAG
+
'
beforeAll
'
)
})
beforeEach
(
async
function
()
{
if
(
i
==
2
){
rdbStore
=
await
dataRdb
.
getRdbStore
(
STORE_CONFIG_NO_KEY
,
1
);
}
rdbStore
=
await
dataRdb
.
getRdbStore
(
STORE_CONFIG
,
1
);
await
rdbStore
.
executeSql
(
CREATE_TABLE_TEST
);
console
.
info
(
TAG
+
'
beforeEach
'
)
})
afterEach
(
async
function
()
{
i
++
;
console
.
info
(
TAG
+
'
afterEach
'
)
rdbStore
=
null
await
dataRdb
.
deleteRdbStore
(
"
EncryptNoKeyInsertTest.db
"
);
})
afterAll
(
async
function
()
{
console
.
info
(
TAG
+
'
afterAll
'
)
})
console
.
log
(
TAG
+
"
*************Unit Test Begin*************
"
);
/**
* @tc.name testRdbStoreChangeEncryptKey0001
* @tc.number SUB_DDM_Encrypt_ChangeKey0001
* @tc.desc encrypt the db at start, then change the encrypt key
*/
it
(
'
testRdbStoreChangeEncryptKey0001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testRdbStoreChangeEncryptKey0001 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
}
var
newKey
=
new
Uint8Array
([
1
,
2
])
await
rdbStore
.
changeEncryptKey
(
newKey
);
let
predicates
=
new
dataRdb
.
RdbPredicates
(
"
test
"
);
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
resultSet
=
await
rdbStore
.
query
(
predicates
)
try
{
console
.
log
(
TAG
+
"
resultSet query done
"
);
resultSet
.
goToFirstRow
()
const
id
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
id
"
))
expect
(
1
).
assertEqual
(
id
);
}
catch
(
e
)
{
console
.
log
(
"
insert1 error
"
+
e
);
}
done
()
console
.
log
(
TAG
+
"
************* testRdbStoreChangeEncryptKey0001 end *************
"
);
})
/**
* @tc.name testRdbStoreChangeEncryptKey0002
* @tc.number SUB_DDM_Encrypt_ChangeKey0002
* @tc.desc encrypt the db at start, then change the encrypt key
*/
it
(
'
testRdbStoreChangeEncryptKey0002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testRdbStoreChangeEncryptKey0002 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
let
result
=
1
;
{
const
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
}
try
{
let
result
=
await
rdbStore
.
changeEncryptKey
(
new
Uint8Array
([
1
,
2
]));
}
catch
(
e
)
{
expect
(
1
).
assertEqual
(
result
);
console
.
log
(
TAG
+
"
can not change encrypt key, since config with no key
"
);
}
done
()
console
.
log
(
TAG
+
"
************* testRdbStoreChangeEncryptKey0002 end *************
"
);
})
/**
* @tc.name testRdbStoreChangeEncryptKey0003
* @tc.number SUB_DDM_Encrypt_ChangeKey0003
* @tc.desc encrypt the db at start, then clear the encrypt key
* now sqlite does not support this feature, switch encrypt to non-encrypt.
*/
it
(
'
testRdbStoreChangeEncryptKey0003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* testRdbStoreChangeEncryptKey0003 start *************
"
);
let
result
=
-
1
;
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
)
}
try
{
result
=
await
rdbStore
.
changeEncryptKey
(
new
Uint8Array
());
}
catch
(
e
)
{
expect
(
-
1
).
assertEqual
(
result
);
console
.
log
(
TAG
+
"
can not clear encrypt key 2
"
);
}
done
()
console
.
log
(
TAG
+
"
************* testRdbStoreChangeEncryptKey0003 end *************
"
);
})
console
.
log
(
TAG
+
"
*************Unit Test End*************
"
);
})
\ No newline at end of file
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstorePredicatesJoinJsunit.test.js
浏览文件 @
60d512ed
...
@@ -113,9 +113,8 @@ describe('rdbStorePredicatesJoinTest', function () {
...
@@ -113,9 +113,8 @@ describe('rdbStorePredicatesJoinTest', function () {
/**
/**
* @tc.name: testRdbJoin001
* @tc.name: testRdbJoin001
* @tc.desc: SUB_DDM_AppDataFWK_Rdb_Inner_Join
* @tc.number: SUB_DDM_AppDataFWK_Rdb_Inner_Join
* @tc.type: FUNC
* @tc.desc: sql query inner join test
* @tc.require: I4NZP6
*/
*/
it
(
'
testRdbJoin001
'
,
0
,
async
function
(
done
)
{
it
(
'
testRdbJoin001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
testRdbJoin001 begin.
"
);
console
.
log
(
TAG
+
"
testRdbJoin001 begin.
"
);
...
@@ -137,9 +136,8 @@ describe('rdbStorePredicatesJoinTest', function () {
...
@@ -137,9 +136,8 @@ describe('rdbStorePredicatesJoinTest', function () {
/**
/**
* @tc.name: testRdbJoin002
* @tc.name: testRdbJoin002
* @tc.desc: SUB_DDM_AppDataFWK_Rdb_Cross_Join
* @tc.number: SUB_DDM_AppDataFWK_Rdb_Cross_Join
* @tc.type: FUNC
* @tc.desc: sql query cross join test
* @tc.require: I4NZP6
*/
*/
it
(
'
testRdbJoin002
'
,
0
,
async
function
(
done
)
{
it
(
'
testRdbJoin002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
testRdbJoin002 begin.
"
);
console
.
log
(
TAG
+
"
testRdbJoin002 begin.
"
);
...
@@ -163,9 +161,8 @@ describe('rdbStorePredicatesJoinTest', function () {
...
@@ -163,9 +161,8 @@ describe('rdbStorePredicatesJoinTest', function () {
/**
/**
* @tc.name: testRdbJoin003
* @tc.name: testRdbJoin003
* @tc.desc: SUB_DDM_AppDataFWK_Rdb_Left_Outer_Join
* @tc.number: SUB_DDM_AppDataFWK_Rdb_Left_Outer_Join
* @tc.type: FUNC
* @tc.desc: sql query left outer join test
* @tc.require: I4NZP6
*/
*/
it
(
'
testRdbJoin003
'
,
0
,
async
function
(
done
)
{
it
(
'
testRdbJoin003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
testRdbJoin003 begin.
"
);
console
.
log
(
TAG
+
"
testRdbJoin003 begin.
"
);
...
...
distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreTransactionJsunit.test.js
浏览文件 @
60d512ed
...
@@ -51,7 +51,7 @@ describe('rdbStoreInsertTest', function () {
...
@@ -51,7 +51,7 @@ describe('rdbStoreInsertTest', function () {
/**
/**
* @tc.name rdb transaction insert test
* @tc.name rdb transaction insert test
* @tc.number SUB_DDM_AppDataFWK_testRdbTransactionInsert0001
* @tc.number SUB_DDM_AppDataFWK_
JSRDB_
testRdbTransactionInsert0001
* @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
* @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
*/
*/
it
(
'
testRdbTransactionInsert0001
'
,
0
,
async
function
(
done
)
{
it
(
'
testRdbTransactionInsert0001
'
,
0
,
async
function
(
done
)
{
...
@@ -86,7 +86,7 @@ describe('rdbStoreInsertTest', function () {
...
@@ -86,7 +86,7 @@ describe('rdbStoreInsertTest', function () {
/**
/**
* @tc.name rdb transaction insert test
* @tc.name rdb transaction insert test
* @tc.number SUB_DDM_AppDataFWK_testRdbTransactionInsert0002
* @tc.number SUB_DDM_AppDataFWK_
JSRDB_
testRdbTransactionInsert0002
* @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
* @tc.desc rdb transaction insert & commit, the result comes out is 3 items;
*/
*/
it
(
'
testRdbTransactionInsert0002
'
,
0
,
async
function
(
done
)
{
it
(
'
testRdbTransactionInsert0002
'
,
0
,
async
function
(
done
)
{
...
@@ -137,7 +137,7 @@ describe('rdbStoreInsertTest', function () {
...
@@ -137,7 +137,7 @@ describe('rdbStoreInsertTest', function () {
/**
/**
* @tc.name rdb transaction insert test
* @tc.name rdb transaction insert test
* @tc.number SUB_DDM_AppDataFWK_testRdbTransactionInsert0003
* @tc.number SUB_DDM_AppDataFWK_
JSRDB_
testRdbTransactionInsert0003
* @tc.desc while using transaction to insert values, querying the db,
* @tc.desc while using transaction to insert values, querying the db,
* the result comes out is 0;
* the result comes out is 0;
*/
*/
...
...
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/DeviceKvStorePromiseJsunit.test.js
浏览文件 @
60d512ed
...
@@ -1568,7 +1568,7 @@ describe('DeviceKvStorePromiseTest', function () {
...
@@ -1568,7 +1568,7 @@ describe('DeviceKvStorePromiseTest', function () {
try
{
try
{
var
count
=
0
;
var
count
=
0
;
kvStore
.
on
(
'
dataChange
'
,
0
,
function
(
data
)
{
kvStore
.
on
(
'
dataChange
'
,
0
,
function
(
data
)
{
console
.
log
(
'
testDeviceKvStore
OnChange001 0
'
+
JSON
.
stringify
(
data
))
console
.
log
(
'
testDeviceKvStore
startTransaction001
'
+
JSON
.
stringify
(
data
))
count
++
;
count
++
;
});
});
await
kvStore
.
startTransaction
().
then
(
async
(
err
)
=>
{
await
kvStore
.
startTransaction
().
then
(
async
(
err
)
=>
{
...
@@ -1621,7 +1621,7 @@ describe('DeviceKvStorePromiseTest', function () {
...
@@ -1621,7 +1621,7 @@ describe('DeviceKvStorePromiseTest', function () {
try
{
try
{
var
count
=
0
;
var
count
=
0
;
kvStore
.
on
(
'
dataChange
'
,
0
,
function
(
data
)
{
kvStore
.
on
(
'
dataChange
'
,
0
,
function
(
data
)
{
console
.
log
(
'
testDeviceKvStore
OnChange001 0
'
+
JSON
.
stringify
(
data
))
console
.
log
(
'
testDeviceKvStore
startTransaction002
'
+
JSON
.
stringify
(
data
))
count
++
;
count
++
;
});
});
await
kvStore
.
startTransaction
().
then
(
async
(
err
)
=>
{
await
kvStore
.
startTransaction
().
then
(
async
(
err
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录