Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8b14daa5
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,发现更多精彩内容 >>
未验证
提交
8b14daa5
编写于
1月 28, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 28, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7283 【xts_acts】【分布式数据管理】【master】新增用例覆盖需求新接口
Merge pull request !7283 from 刘皓男/master
上级
cd875a1b
4c548a70
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
339 addition
and
1 deletion
+339
-1
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreInsertJsunit.test.js
.../hap/src/main/js/test/RelationalStoreInsertJsunit.test.js
+339
-1
未找到文件。
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreInsertJsunit.test.js
浏览文件 @
8b14daa5
...
...
@@ -1088,6 +1088,344 @@ describe('relationalStoreInsertTest', function () {
console
.
info
(
TAG
+
"
************* testRdbStorebatchInsertCallback0007 end *************
"
);
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
);
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0001
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0001 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_NONE
);
}
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
try
{
let
insertPromise
=
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_NONE
);
insertPromise
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
);
console
.
log
(
TAG
+
"
InsertWithConflictResolution0001 insert first done:
"
+
ret
);
expect
(
null
).
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0001 insert with wrong valuebucket and ConflictResolution is default
"
)
done
();
})
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0001 catch err: failed, err: code=
"
+
err
.
code
+
"
message=
"
+
err
.
message
)
expect
(
"
401
"
).
assertEqual
(
err
.
code
);
expect
(
null
).
assertFail
();
}
}
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution_0001 end *************
"
);
})
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0002
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0002 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_ROLLBACK
);
}
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
try
{
let
insertPromise
=
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_ROLLBACK
);
insertPromise
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
)
console
.
log
(
TAG
+
"
InsertWithConflictResolution0002 insert first done:
"
+
ret
)
expect
(
null
).
assertFail
()
}).
catch
((
err
)
=>
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0002 insert with wrong valuebucket and ConflictResolution is ON_CONFLICT_ROLLBACK
"
)
done
()
})
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0002 catch err: failed, err: code=
"
+
err
.
code
+
"
message=
"
+
err
.
message
)
expect
(
"
401
"
).
assertEqual
(
err
.
code
)
expect
(
null
).
assertFail
()
}
}
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution_0002 end *************
"
);
})
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0003
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0003 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_IGNORE
);
}
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_IGNORE
);
}
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
);
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
resultSet
=
await
rdbStore
.
query
(
predicates
)
try
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0003 resultSet query done
"
);
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
id
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
id
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
console
.
log
(
TAG
+
"
InsertWithConflictResolution0004 id=
"
+
id
+
"
, salary=
"
+
salary
);
expect
(
1
).
assertEqual
(
id
);
expect
(
100.5
).
assertEqual
(
salary
)
expect
(
false
).
assertEqual
(
resultSet
.
goToNextRow
())
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0003 insert error
"
+
err
);
}
resultSet
=
null
done
()
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution_0003 end *************
"
);
})
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0004
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0004 start *************
"
);
{
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_REPLACE
);
}
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
test
"
);
predicates
.
equalTo
(
"
name
"
,
"
zhangsan
"
)
let
resultSet
=
await
rdbStore
.
query
(
predicates
)
try
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0004 resultSet query done
"
);
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
id
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
id
"
))
expect
(
1
).
assertEqual
(
id
);
expect
(
false
).
assertEqual
(
resultSet
.
goToNextRow
())
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0004 insert error
"
+
err
);
}
{
var
u8
=
new
Uint8Array
([
4
,
5
,
6
])
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_REPLACE
);
}
resultSet
=
await
rdbStore
.
query
(
predicates
)
try
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0004 resultSet query done
"
);
expect
(
true
).
assertEqual
(
resultSet
.
goToFirstRow
())
const
id
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
id
"
))
const
name
=
resultSet
.
getString
(
resultSet
.
getColumnIndex
(
"
name
"
))
const
age
=
resultSet
.
getLong
(
resultSet
.
getColumnIndex
(
"
age
"
))
const
salary
=
resultSet
.
getDouble
(
resultSet
.
getColumnIndex
(
"
salary
"
))
const
blobType
=
resultSet
.
getBlob
(
resultSet
.
getColumnIndex
(
"
blobType
"
))
console
.
log
(
TAG
+
"
InsertWithConflictResolution0004 id=
"
+
id
+
"
, name=
"
+
name
+
"
, age=
"
+
age
+
"
, salary=
"
+
salary
+
"
, blobType=
"
+
blobType
);
expect
(
1
).
assertEqual
(
id
);
expect
(
"
zhangsan
"
).
assertEqual
(
name
)
expect
(
18
).
assertEqual
(
age
)
expect
(
200.5
).
assertEqual
(
salary
)
expect
(
4
).
assertEqual
(
blobType
[
0
])
expect
(
5
).
assertEqual
(
blobType
[
1
])
expect
(
6
).
assertEqual
(
blobType
[
2
])
expect
(
false
).
assertEqual
(
resultSet
.
goToNextRow
())
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0004 resultSet query error
"
+
err
);
}
resultSet
=
null
done
()
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution_0004 end *************
"
);
})
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0005
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0005
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0005 start *************
"
);
{
var
u8
=
new
Uint8Array
([
4
,
5
,
6
])
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
try
{
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
6
);
expect
(
null
).
assertFail
()
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0005 catch err: failed, err: code=
"
+
err
.
code
+
"
message=
"
+
err
.
message
)
expect
(
"
401
"
).
assertEqual
(
err
.
code
)
done
()
}
}
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution_0005 end *************
"
);
})
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0006
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0006
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0006 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_ABORT
);
}
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
try
{
let
insertPromise
=
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_ABORT
);
insertPromise
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
)
console
.
log
(
TAG
+
"
InsertWithConflictResolution0006 insert first done:
"
+
ret
)
expect
(
null
).
assertFail
()
}).
catch
((
err
)
=>
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0006 insert with wrong valuebucket and ConflictResolution is ON_CONFLICT_ABORT
"
)
done
()
})
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0006 catch err: failed, err: code=
"
+
err
.
code
+
"
message=
"
+
err
.
message
)
expect
(
"
401
"
).
assertEqual
(
err
.
code
)
expect
(
null
).
assertFail
()
}
}
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0006 end *************
"
);
})
/**
* @tc.name rdb inserttWithConflictResolution test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_InsertWithConflictResolution_0007
* @tc.desc rdb insertWithConflictResolution test
*/
it
(
'
InsertWithConflictResolution0007
'
,
0
,
async
function
(
done
)
{
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0007 start *************
"
);
var
u8
=
new
Uint8Array
([
1
,
2
,
3
])
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
100.5
,
"
blobType
"
:
u8
,
}
await
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_FAIL
);
}
{
const
valueBucket
=
{
"
id
"
:
1
,
"
name
"
:
"
zhangsan
"
,
"
age
"
:
18
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
try
{
let
insertPromise
=
rdbStore
.
insert
(
"
test
"
,
valueBucket
,
data_Rdb
.
ConflictResolution
.
ON_CONFLICT_FAIL
);
insertPromise
.
then
(
async
(
ret
)
=>
{
expect
(
1
).
assertEqual
(
ret
)
console
.
log
(
TAG
+
"
InsertWithConflictResolution0007 insert first done:
"
+
ret
)
expect
(
null
).
assertFail
()
}).
catch
((
err
)
=>
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0007 insert with wrong valuebucket and ConflictResolution is ON_CONFLICT_FAIL
"
)
done
()
})
}
catch
(
err
)
{
console
.
log
(
TAG
+
"
InsertWithConflictResolution0007 catch err: failed, err: code=
"
+
err
.
code
+
"
message=
"
+
err
.
message
)
expect
(
"
401
"
).
assertEqual
(
err
.
code
)
expect
(
null
).
assertFail
()
}
}
console
.
log
(
TAG
+
"
************* InsertWithConflictResolution0007 end *************
"
);
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
);
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录