未验证 提交 9516304c 编写于 作者: O openharmony_ci 提交者: Gitee

!2901 【Distributeddatamgr】【Master】RdbstoreDeleteJsunit.test.js,RdbStoreResultSetJsunit.test.js 文件修改

Merge pull request !2901 from 杨立峰/master
......@@ -15,13 +15,13 @@
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 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: "Delete.db",
name: 'Delete.db',
}
var rdbStore = undefined;
let rdbStore = undefined;
describe('rdbStoreDeleteTest', function () {
beforeAll(function () {
......@@ -36,65 +36,65 @@ describe('rdbStoreDeleteTest', function () {
afterEach(async function () {
console.info(TAG + 'afterEach')
await rdbStore.executeSql("DELETE FROM test");
await rdbStore.executeSql('DELETE FROM test');
rdbStore = null
await dataRdb.deleteRdbStore("Delete.db");
await dataRdb.deleteRdbStore('Delete.db');
})
afterAll(async function () {
console.info(TAG + 'afterAll')
})
console.log(TAG + "*************Unit Test Begin*************");
console.log(TAG + '*************Unit Test Begin*************');
/**
* @tc.name rdb delete test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Delete_0010
* @tc.desc rdb delete test
*/
it('testRdbStoreDelete0001', 0, async function (done) {
console.log(TAG + "************* testRdbStoreDelete0001 start *************");
var u8 = new Uint8Array([1, 2, 3])
console.log(TAG + '************* testRdbStoreDelete0001 start *************');
let u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
'name': 'zhangsan',
'age': 18,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 28,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 28,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 38,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 38,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
//删除
{
let predicates = await new dataRdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates('test')
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
expect(3).assertEqual(ret)
console.log(TAG + "Delete done: " + ret)
console.log(TAG + 'Delete done: ' + ret)
}).catch((err) => {
expect(null).assertFail()
})
await deletePromise
}
done()
console.log(TAG + "************* testRdbStoreDelete0001 end *************");
console.log(TAG + '************* testRdbStoreDelete0001 end *************');
})
/**
......@@ -103,50 +103,50 @@ describe('rdbStoreDeleteTest', function () {
* @tc.desc rdb delete test
*/
it('testRdbStoreDelete0002', 0, async function (done) {
console.log(TAG + "************* testRdbStoreDelete0002 start *************");
var u8 = new Uint8Array([1, 2, 3])
console.log(TAG + '************* testRdbStoreDelete0002 start *************');
let u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
'name': 'zhangsan',
'age': 18,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 28,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 28,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 38,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 38,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
//删除
{
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "zhangsan")
let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('name', 'zhangsan')
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
await expect(1).assertEqual(ret)
await console.log(TAG + "Delete done: " + ret)
await console.log(TAG + 'Delete done: ' + ret)
}).catch((err) => {
expect(null).assertFail()
})
await deletePromise
}
done()
console.log(TAG + "************* testRdbStoreDelete0002 end *************");
console.log(TAG + '************* testRdbStoreDelete0002 end *************');
})
/**
......@@ -155,41 +155,41 @@ describe('rdbStoreDeleteTest', function () {
* @tc.desc rdb delete test
*/
it('testRdbStoreDelete0003', 0, async function (done) {
console.log(TAG + "************* testRdbStoreDelete0003 start *************");
var u8 = new Uint8Array([1, 2, 3])
console.log(TAG + '************* testRdbStoreDelete0003 start *************');
let u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
'name': 'zhangsan',
'age': 18,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 28,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 28,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
//删除前查询
{
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('age', 28)
let resultSet = await rdbStore.query(predicates)
expect(1).assertEqual(resultSet.rowCount)
}
//删除
{
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('age', 28)
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
expect(1).assertEqual(ret)
console.log(TAG + "Delete done: " + ret)
console.log(TAG + 'Delete done: ' + ret)
}).catch((err) => {
expect(null).assertFail()
})
......@@ -197,13 +197,13 @@ describe('rdbStoreDeleteTest', function () {
}
//删除后查询
{
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28)
let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('age', 28)
let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount)
}
done()
console.log(TAG + "************* testRdbStoreDelete0003 end *************");
console.log(TAG + '************* testRdbStoreDelete0003 end *************');
})
/**
......@@ -212,49 +212,49 @@ describe('rdbStoreDeleteTest', function () {
* @tc.desc rdb delete test
*/
it('testRdbStoreDelete0004', 0, async function (done) {
console.log(TAG + "************* testRdbStoreDelete0004 start *************");
var u8 = new Uint8Array([1, 2, 3])
console.log(TAG + '************* testRdbStoreDelete0004 start *************');
let u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
'name': 'zhangsan',
'age': 18,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 28,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 28,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 38,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 38,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
//删除
{
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("aaa id", 1)
let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('aaa id', 1)
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
console.log(TAG + "delete done: " + ret)
console.log(TAG + 'delete done: ' + ret)
expect(null).assertFail()
}).catch((err) => {
console.log(TAG + "delete with wrong conditions")
console.log(TAG + 'delete with wrong conditions')
})
}
done()
console.log(TAG + "************* testRdbStoreDelete0004 end *************");
console.log(TAG + '************* testRdbStoreDelete0004 end *************');
})
/**
......@@ -263,50 +263,50 @@ describe('rdbStoreDeleteTest', function () {
* @tc.desc rdb delete test
*/
it('testRdbStoreDelete0005', 0, async function (done) {
console.log(TAG + "************* testRdbStoreDelete0005 start *************");
var u8 = new Uint8Array([1, 2, 3])
console.log(TAG + '************* testRdbStoreDelete0005 start *************');
let u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
'name': 'zhangsan',
'age': 18,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 28,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 28,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 38,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 38,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
//删除
{
let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "lisi")
let predicates = await new dataRdb.RdbPredicates('test')
predicates.equalTo('name', 'lisi')
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
expect(2).assertEqual(ret)
console.log(TAG + "Delete done: " + ret)
console.log(TAG + 'Delete done: ' + ret)
}).catch((err) => {
expect(null).assertFail()
})
await deletePromise
}
done()
console.log(TAG + "************* testRdbStoreDelete0005 end *************");
console.log(TAG + '************* testRdbStoreDelete0005 end *************');
})
/**
......@@ -315,49 +315,49 @@ describe('rdbStoreDeleteTest', function () {
* @tc.desc rdb delete test
*/
it('testRdbStoreDelete0006', 0, async function (done) {
console.log(TAG + "************* testRdbStoreDelete0006 start *************");
var u8 = new Uint8Array([1, 2, 3])
console.log(TAG + '************* testRdbStoreDelete0006 start *************');
let u8 = new Uint8Array([1, 2, 3])
{
const valueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": u8,
'name': 'zhangsan',
'age': 18,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 28,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 28,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
{
const valueBucket = {
"name": "lisi",
"age": 38,
"salary": 100.5,
"blobType": u8,
'name': 'lisi',
'age': 38,
'salary': 100.5,
'blobType': u8,
}
await rdbStore.insert("test", valueBucket)
await rdbStore.insert('test', valueBucket)
}
//删除
{
let predicates = await new dataRdb.RdbPredicates("")
let predicates = await new dataRdb.RdbPredicates('')
let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => {
console.log(TAG + "delete done: " + ret)
console.log(TAG + 'delete done: ' + ret)
expect(null).assertFail()
}).catch((err) => {
console.log(TAG + "delete with null")
console.log(TAG + 'delete with null')
})
}
done()
console.log(TAG + "************* testRdbStoreDelete0006 end *************");
console.log(TAG + '************* testRdbStoreDelete0006 end *************');
})
console.log(TAG + "*************Unit Test End*************");
console.log(TAG + '*************Unit Test End*************');
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册