提交 fd1732a7 编写于 作者: X xsterling

testcase update.

Signed-off-by: Nxsterling <huangjiaqi19@huawei.com>
上级 24459f98
...@@ -854,19 +854,21 @@ describe('DeviceKvStoreCallbackTest', function () { ...@@ -854,19 +854,21 @@ describe('DeviceKvStoreCallbackTest', function () {
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, function (err,data) {
console.log('testDeviceKvStoreOnSyncComplete101 put success'); console.log('testDeviceKvStoreOnSyncComplete101 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete101 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY; var mode = factory.SyncMode.PULL_ONLY;
try {
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
} catch(e) { } catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e);
} }
done();
});
}catch(e) { }catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 no peer device :e:' + e); console.log('testDeviceKvStoreOnSyncComplete101 no peer device :e:' + e);
done();
} }
done();
}) })
/** /**
...@@ -883,19 +885,21 @@ describe('DeviceKvStoreCallbackTest', function () { ...@@ -883,19 +885,21 @@ describe('DeviceKvStoreCallbackTest', function () {
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, function (err,data) {
console.log('testDeviceKvStoreOnSyncComplete102 put success'); console.log('testDeviceKvStoreOnSyncComplete102 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete102 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY; var mode = factory.SyncMode.PUSH_ONLY;
try {
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
} catch(e) { } catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); console.log('testDeviceKvStoreOnSyncComplete102 sync no peer device :e:' + e);
} }
done();
});
}catch(e) { }catch(e) {
console.log('testDeviceKvStoreOnSyncComplete102 no peer device :e:' + e); console.log('testDeviceKvStoreOnSyncComplete102 no peer device :e:' + e);
done();
} }
done();
}) })
/** /**
...@@ -912,19 +916,21 @@ describe('DeviceKvStoreCallbackTest', function () { ...@@ -912,19 +916,21 @@ describe('DeviceKvStoreCallbackTest', function () {
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, function (err,data) {
console.log('testDeviceKvStoreOnSyncComplete103 put success'); console.log('testDeviceKvStoreOnSyncComplete103 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete103 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL; var mode = factory.SyncMode.PUSH_PULL;
try {
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
} catch(e) { } catch(e) {
console.log('testDeviceKvStoreOnSyncComplete101 sync no peer device :e:' + e); console.log('testDeviceKvStoreOnSyncComplete103 sync no peer device :e:' + e);
} }
done();
});
}catch(e) { }catch(e) {
console.log('testDeviceKvStoreOnSyncComplete103 no peer device :e:' + e); console.log('testDeviceKvStoreOnSyncComplete103 no peer device :e:' + e);
done();
} }
done();
}) })
/** /**
......
...@@ -860,14 +860,19 @@ describe('DeviceKvStorePromiseTest', function () { ...@@ -860,14 +860,19 @@ describe('DeviceKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete001 put success'); console.log('testDeviceKvStoreOnSyncComplete001 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete001 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY; var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
}).catch((error) => { } catch (e) {
console.log('testDeviceKvStoreOnSyncComplete001 no peer device :e:' + error); console.log('testDeviceKvStoreOnSyncComplete001 sync no peer device :e:' + e);
}); }
}catch(e) { } catch(e) {
console.log('testDeviceKvStoreOnSyncComplete001 put e ' + e); console.log('testDeviceKvStoreOnSyncComplete001 e ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
...@@ -887,13 +892,18 @@ describe('DeviceKvStorePromiseTest', function () { ...@@ -887,13 +892,18 @@ describe('DeviceKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete002 put success'); console.log('testDeviceKvStoreOnSyncComplete002 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete002 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY; var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
}).catch((error) => { } catch(error) {
console.log('testDeviceKvStoreOnSyncComplete002 no peer device :e:' + error); console.log('testDeviceKvStoreOnSyncComplete002 no peer device :e:' + error);
}); };
}catch(e) { } catch(e) {
console.log('testDeviceKvStoreOnSyncComplete002 put e ' + e); console.log('testDeviceKvStoreOnSyncComplete002 put e ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
...@@ -914,13 +924,18 @@ describe('DeviceKvStorePromiseTest', function () { ...@@ -914,13 +924,18 @@ describe('DeviceKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testDeviceKvStoreOnSyncComplete003 put success'); console.log('testDeviceKvStoreOnSyncComplete003 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
}).catch((error) => {
console.log('testDeviceKvStoreOnSyncComplete002 put failed:' + e);
expect(null).assertFail();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL; var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode); kvStore.sync(devices, mode);
}).catch((error) => { } catch(error) {
console.log('testDeviceKvStoreOnSyncComplete003 no peer device :e:' + error); console.log('testDeviceKvStoreOnSyncComplete003 no peer device :e:' + error);
}); };
}catch(e) { } catch(e) {
console.log('testDeviceKvStoreOnSyncComplete003 put e ' + e); console.log('testDeviceKvStoreOnSyncComplete003 put e ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
......
...@@ -262,4 +262,25 @@ describe('SchemaTest', function() { ...@@ -262,4 +262,25 @@ describe('SchemaTest', function() {
} }
done(); done();
}) })
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_TOJSONSTRING_0400
* @tc.name [JS-API8]Schema.ToJsonString()
* @tc.desc Test Js Api Schema.ToJsonString() testcase 004
*/
it('testToJsonString004', 0, async function(done) {
try {
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
let schema = new ddm.Schema();
schema.root.appendChild(english);
schema.indexes = []; // indexex set to empty array.
console.log("schema: " + schema.toJsonString());
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
}) })
\ No newline at end of file
...@@ -821,11 +821,14 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -821,11 +821,14 @@ describe('SingleKvStoreCallbackTest', function () {
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, function (err,data) {
console.log('testSingleKvStoreOnSyncComplete101 put success'); console.log('testSingleKvStoreOnSyncComplete101 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY; var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10); kvStore.sync(devices, mode, 10);
done(); } catch (e) {
}); console.log('testSingleKvStoreOnSyncComplete101 sync no peer device :e:' + e);
}
}catch(e) { }catch(e) {
console.log('testSingleKvStoreOnSyncComplete101 e' + e); console.log('testSingleKvStoreOnSyncComplete101 e' + e);
expect(null).assertFail(); expect(null).assertFail();
...@@ -844,19 +847,22 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -844,19 +847,22 @@ describe('SingleKvStoreCallbackTest', function () {
console.log('testSingleKvStoreOnSyncComplete102 dataChange'); console.log('testSingleKvStoreOnSyncComplete102 dataChange');
expect(data != null).assertTrue(); 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 + 'testSync102', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
console.log('testSingleKvStoreOnSyncComplete102 put success'); console.log('testSingleKvStoreOnSyncComplete102 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY; var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10); kvStore.sync(devices, mode, 10);
done(); } catch (e) {
}); console.log('testSingleKvStoreOnSyncComplete102 sync no peer device :e:' + e);
}
}catch(e) { }catch(e) {
console.log('testSingleKvStoreOnSyncComplete102 e' + e); console.log('testSingleKvStoreOnSyncComplete102 e' + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -870,19 +876,22 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -870,19 +876,22 @@ describe('SingleKvStoreCallbackTest', function () {
console.log('testSingleKvStoreOnSyncComplete103 dataChange'); console.log('testSingleKvStoreOnSyncComplete103 dataChange');
expect(data != null).assertTrue(); 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 + 'testSync103', VALUE_TEST_SYNC_ELEMENT, function (err,data) {
console.log('testSingleKvStoreOnSyncComplete103 put success'); console.log('testSingleKvStoreOnSyncComplete103 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
});
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB']; var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL; var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10); kvStore.sync(devices, mode, 10);
done(); } catch (e) {
}); console.log('testSingleKvStoreOnSyncComplete103 sync no peer device :e:' + e);
}
}catch(e) { }catch(e) {
console.log('testSingleKvStoreOnSyncComplete103 e' + e); console.log('testSingleKvStoreOnSyncComplete103 e' + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
......
...@@ -830,15 +830,19 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -830,15 +830,19 @@ describe('SingleKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testSingleKvStoreOnSyncComplete001 put success'); console.log('testSingleKvStoreOnSyncComplete001 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10);
}).catch((error) => { }).catch((error) => {
console.log('testSingleKvStoreOnSyncComplete001 put fail ' + error); console.log('testSingleKvStoreOnSyncComplete001 put fail ' + error);
expect(null).assertFail(); expect(null).assertFail();
}); });
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PULL_ONLY;
kvStore.sync(devices, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete001 sync no peer device :e:' + e);
}
}catch(e) { }catch(e) {
console.log('testSingleKvStoreOnSyncComplete001 put e ' + e); console.log('testSingleKvStoreOnSyncComplete001 e ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
...@@ -858,15 +862,19 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -858,15 +862,19 @@ describe('SingleKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testSingleKvStoreOnSyncComplete002 put success'); console.log('testSingleKvStoreOnSyncComplete002 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10);
}).catch((error) => { }).catch((error) => {
console.log('testSingleKvStoreOnSyncComplete002 put fail ' + error); console.log('testSingleKvStoreOnSyncComplete002 put fail ' + error);
expect(null).assertFail(); expect(null).assertFail();
}); });
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_ONLY;
kvStore.sync(devices, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete002 sync no peer device :e:' + e);
}
}catch(e) { }catch(e) {
console.log('testSingleKvStoreOnSyncComplete002 put e ' + e); console.log('testSingleKvStoreOnSyncComplete002 e ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
...@@ -886,15 +894,19 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -886,15 +894,19 @@ describe('SingleKvStorePromiseTest', function () {
await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_SYNC_ELEMENT, VALUE_TEST_SYNC_ELEMENT).then((data) => {
console.log('testSingleKvStoreOnSyncComplete003 put success'); console.log('testSingleKvStoreOnSyncComplete003 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10);
}).catch((error) => { }).catch((error) => {
console.log('testSingleKvStoreOnSyncComplete003 put fail ' + error); console.log('testSingleKvStoreOnSyncComplete003 put fail ' + error);
expect(null).assertFail(); expect(null).assertFail();
}); });
try {
var devices = ['A12C1F9261528B21F95778D2FDC0B2E33943E6251AC5487F4473D005758905DB'];
var mode = factory.SyncMode.PUSH_PULL;
kvStore.sync(devices, mode, 10);
} catch (e) {
console.log('testSingleKvStoreOnSyncComplete003 sync no peer device :e:' + e);
}
}catch(e) { }catch(e) {
console.log('testSingleKvStoreOnSyncComplete003 put e ' + e); console.log('testSingleKvStoreOnSyncComplete003 e ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册