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

!3329 【Distributeddatamgr】【master】新增用例

Merge pull request !3329 from 梁梁/master
......@@ -21,6 +21,7 @@ const CREATE_TABLE_TEST = 'CREATE TABLE IF NOT EXISTS test (' + 'id INTEGER PRIM
const STORE_CONFIG = {
name: 'Resultset.db',
}
const COLOUNM_NAMES = ["id","data1","data2","data3","data4"];
var rdbStore = undefined;
describe('rdbResultSetTest', function () {
......@@ -1746,5 +1747,26 @@ describe('rdbResultSetTest', function () {
}
})
/**
* @tc.name resultSet columnNames test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_ResultSet_0240
* @tc.desc resultSet columnNames test
*/
it('testcolumnNames0001', 0, async function (done) {
console.log(TAG + '************* testcolumnNames0001 start *************');
{
let predicates = await new dataRdb.RdbPredicates('test')
let resultSet = await rdbStore.query(predicates)
if (COLOUNM_NAMES == resultSet.columnNames){
expect(1).assertEqual(0);
}else{
expect(0).assertEqual(0);
}
resultSet = null;
done();
console.log(TAG + '************* testcolumnNames0001 end *************');
}
})
console.log(TAG + '*************Unit Test End*************');
})
\ No newline at end of file
})
......@@ -276,7 +276,7 @@ describe('storageTest', function () {
/**
* @tc.name clear、put、get、flush String callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0120
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0172
* @tc.desc flush String callback interface test
*/
it('testCallback0172', 0, function (done) {
......@@ -317,4 +317,19 @@ describe('storageTest', function () {
});
});
})
})
\ No newline at end of file
/**
* @tc.name delete callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0180
* @tc.desc delete callback interface test
*/
it('testDelete0182', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
expect("abc").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
mPref.delete(KEY_TEST_STRING_ELEMENT,(err,ret)=>{
expect("default").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"))
});
done();
})
})
......@@ -24,14 +24,24 @@ const KEY_TEST_STRING_ELEMENT = 'key_test_string';
var mPref;
describe('storageTest', function () {
beforeAll(function () {
beforeAll(async function () {
console.info('beforeAll')
mPref = storage.getStorageSync(PATH);
const promise = storage.getStorage(PATH);
promise.then((Storage)=>{
mPref = Storage;
});
await promise;
done();
})
afterAll(function () {
afterAll(async function (done) {
console.info('afterAll')
storage.deleteStorageSync(PATH);
const promise = storage.deleteStorage(PATH);
promise.then(()=>{
console.log('Delete Storage finish');
});
await promise;
done();
})
/**
......@@ -364,4 +374,79 @@ describe('storageTest', function () {
await promise;
done();
})
})
\ No newline at end of file
/**
* @tc.name Maximum length of key test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0200
* @tc.desc Maximum length of key test
*/
it('testMaxLengthofKety0200', 0, async function(done){
mPref.clearSync();
const promise = mPref.put(MAX_KEY_LENGTH,"value1")
promise.then((ret)=>{
expect("value1").assertEqual(mPref.getSync(MAX_KEY_LENGTH,"defaultvalue"))
}).catch((err)=>{
expect(null).assertFail();
})
await promise;
done();
})
/**
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0210
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0210', 0, async function (done) {
mPref.clearSync();
mPref.putSync("test", "abc");
const promise = mPref.put("test", MAX_VALUE_LENGTH);
promise.then((ret) => {
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name Maximum length of value test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0220
* @tc.desc Maximum length of value test
*/
it('testMaxLengthofValue0220', 0, async function (done) {
mPref.clearSync();
mPref.putSync("test",MAX_VALUE_LENGTH)
const promise = mPref.put("test", "y".repeat(8192));
promise.then((ret) => {
expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name delete promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0230
* @tc.desc delete promise interface test
*/
it('testDelete0230', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
expect("abc").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "default"));
const promise = mPref.delete(KEY_TEST_STRING_ELEMENT);
promise.then((ret)=>{
expect("default").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT,"default"));
}).catch((err)=>{
expect('').assertFail();
});
await promise;
done();
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册