提交 846c5141 编写于 作者: X xsterling

testcase update.

Signed-off-by: Nxsterling <huangjiaqi19@huawei.com>
上级 9c03ee37
......@@ -32,6 +32,9 @@ const TEST_STORE_ID = 'storeId';
var kvManager = null;
var kvStore = null;
var localDeviceId = null;
const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
......@@ -137,6 +140,7 @@ describe('DeviceKvStoreCallbackTest', function () {
done();
});
});
kvStore = null;
})
/**
......@@ -851,22 +855,23 @@ describe('DeviceKvStoreCallbackTest', function () {
console.log('testDeviceKvStoreOnSyncComplete101 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete101 put success');
expect(err == undefined).assertTrue();
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete101 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 no peer device :e:' + e);
expect(null).assertFail();
}
done();
})
......@@ -882,22 +887,23 @@ describe('DeviceKvStoreCallbackTest', function () {
console.log('testDeviceKvStoreOnSyncComplete102 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete102 put success');
expect(err == undefined).assertTrue();
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete102 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete102 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete102 no peer device :e:' + e);
expect(null).assertFail();
}
done();
})
......@@ -913,22 +919,23 @@ describe('DeviceKvStoreCallbackTest', function () {
console.log('testDeviceKvStoreOnSyncComplete103 dataChange');
expect(data != null).assertTrue();
});
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
await kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete103 put success');
expect(err == undefined).assertTrue();
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete103 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete103 sync no peer device :e:' + e);
}
}catch(e) {
console.log('testDeviceKvStoreOnSyncComplete103 no peer device :e:' + e);
expect(null).assertFail();
}
done();
})
......
......@@ -32,6 +32,9 @@ const TEST_STORE_ID = 'storeId';
var kvManager = null;
var kvStore = null;
var localDeviceId = null;
const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
......@@ -137,13 +140,13 @@ describe('DeviceKvStorePromiseTest', function () {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -865,9 +868,9 @@ describe('DeviceKvStorePromiseTest', function () {
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch (e) {
console.log('testDeviceKvStoreOnSyncComplete001 sync no peer device :e:' + e);
}
......@@ -897,12 +900,12 @@ describe('DeviceKvStorePromiseTest', function () {
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(error) {
console.log('testDeviceKvStoreOnSyncComplete002 no peer device :e:' + error);
};
}
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete002 put e ' + e);
expect(null).assertFail();
......@@ -925,16 +928,16 @@ describe('DeviceKvStorePromiseTest', function () {
console.log('testDeviceKvStoreOnSyncComplete003 put success');
expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete002 put failed:' + e);
console.log('testDeviceKvStoreOnSyncComplete003 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode);
} catch(error) {
console.log('testDeviceKvStoreOnSyncComplete003 no peer device :e:' + error);
};
}
} catch(e) {
console.log('testDeviceKvStoreOnSyncComplete003 put e ' + e);
expect(null).assertFail();
......
......@@ -15,9 +15,6 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import ddm from '@ohos.data.distributedData';
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
describe('FieldNodeTest', function() {
/**
......
......@@ -67,6 +67,7 @@ describe('KVManagerCallbackTest', function () {
done();
});
});
kvStore = null;
})
/**
......@@ -725,16 +726,23 @@ describe('KVManagerCallbackTest', function () {
it('testKVManagerCloseKVStore104', 0, async function (done) {
console.log('testKVManagerCloseKVStore104');
try {
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVManagerCloseKVStore104 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
});
console.log('testKVManagerCloseKVStore104 closeKVStore redo.');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, function (err, data) {
console.log('testKVManagerCloseKVStore104 closeKVStore success');
expect((err == undefined) && (data == undefined)).assertTrue();
done();
console.log('testKVManagerCloseKVStore104 closeKVStore twice ' + err);
if (err == undefined) {
expect(null).assertFail();
}
});
} catch (e) {
console.log('testKVManagerCloseKVStore104 e ' + e);
console.log('testKVManagerCloseKVStore104 closeKVStore twice e ' + e);
expect(null).assertFail();
done();
}
done();
})
/**
......
......@@ -73,6 +73,7 @@ describe('KVManagerPromiseTest', function () {
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -659,11 +660,17 @@ describe('KVManagerPromiseTest', function () {
*/
it('testKVManagerCloseKVStore004', 0, async function (done) {
console.log('testKVManagerCloseKVStore004');
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVManagerCloseKVStore004 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
});
console.log('testKVManagerCloseKVStore104 closeKVStore redo.');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => {
console.log('testKVManagerCloseKVStore004 closeKVStore success');
}).catch((err) => {
console.log('testKVManagerCloseKVStore004 closeKVStore err ' + err);
console.log('testKVManagerCloseKVStore004 closeKVStore twice');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore004 closeKVStore twice err ' + err);
});
done();
})
......
......@@ -120,13 +120,14 @@ describe('KvStoreResultSetTest', function() {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
resultSet = null;
done();
})
......@@ -581,12 +582,12 @@ describe('KvStoreResultSetTest', function() {
expect(moved && (resultSet.getPosition() == 0)).assertTrue();
moved = resultSet.moveToPrevious();
console.log("testKvStoreResultSetMoveToPrevious005 from 0 to -1 return" + moved);
expect(moved).assertFalse();
expect(moved == false).assertTrue();
console.log("testKvStoreResultSetMoveToPrevious005 from 0 to " + resultSet.getPosition());
expect(-1).assertEqual(resultSet.getPosition());
} catch (e) {
console.log("testKvStoreResultSetMoveToPrevious005 fail " + e);
expect(null).assertTrue();
expect(null).assertFail();
}
done();
})
......@@ -965,7 +966,7 @@ describe('KvStoreResultSetTest', function() {
expect(moved).assertTrue();
moved = resultSet.moveToNext();
console.log("testKvStoreResultSetIsAfterLast002 moveToNext moved=" + moved);
expect(moved).assertFalse();
expect(moved == false).assertTrue();
var flag = resultSet.isAfterLast();
console.log("testKvStoreResultSetIsAfterLast002 isAfterLast true=" + flag);
expect(flag).assertTrue();
......
......@@ -136,13 +136,13 @@ describe('SchemaTest', function() {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......
......@@ -31,6 +31,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const TEST_STORE_ID = 'storeId';
var kvManager = null;
var kvStore = null;
const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
......@@ -104,6 +107,7 @@ describe('SingleKvStoreCallbackTest', function () {
done();
});
});
kvStore = null;
})
/**
......@@ -823,9 +827,9 @@ describe('SingleKvStoreCallbackTest', function () {
expect(err == undefined).assertTrue();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
......@@ -852,9 +856,9 @@ describe('SingleKvStoreCallbackTest', function () {
expect(err == undefined).assertTrue();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete102 sync no peer device :e:' + e);
}
......@@ -881,9 +885,9 @@ describe('SingleKvStoreCallbackTest', function () {
expect(err == undefined).assertTrue();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete103 sync no peer device :e:' + e);
}
......
......@@ -48,7 +48,7 @@ describe('KvStoreEnumTest', function () {
var maxValueLength = factory.Constants.MAX_VALUE_LENGTH;
console.info('maxValueLength = ' + maxValueLength);
expect(maxValueLength == 4194303).assertTrue();
expect( factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
})
/**
......@@ -63,7 +63,6 @@ describe('KvStoreEnumTest', function () {
console.info('can NOT set value to MAX_VALUE_LENGTH : ' + e);
expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
}
})
/**
......
......@@ -31,6 +31,9 @@ const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr';
const TEST_STORE_ID = 'storeId';
var kvManager = null;
var kvStore = null;
const USED_DEVICE_IDS = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
const UNUSED_DEVICE_IDS = []; /* add you test device-ids here */
var syncDeviceIds = USED_DEVICE_IDS.concat(UNUSED_DEVICE_IDS);
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
......@@ -107,13 +110,13 @@ describe('SingleKvStorePromiseTest', function () {
console.log('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('afterEach deleteKVStore success');
kvStore = null;
}).catch((err) => {
console.log('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.log('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
......@@ -835,9 +838,9 @@ describe('SingleKvStorePromiseTest', function () {
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete001 sync no peer device :e:' + e);
}
......@@ -867,9 +870,9 @@ describe('SingleKvStorePromiseTest', function () {
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete002 sync no peer device :e:' + e);
}
......@@ -899,9 +902,9 @@ describe('SingleKvStorePromiseTest', function () {
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10);
console.log('kvStore.sync to ' + JSON.stringify(syncDeviceIds));
kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete003 sync no peer device :e:' + e);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册