aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavidCai <davidcai1993@yahoo.com>2017-03-27 21:54:41 +0800
committerJames M Snell <jasnell@gmail.com>2017-04-04 11:50:36 -0700
commit610ac7d8581012e627a4f4b67450b423ddbda415 (patch)
tree713753488434028cc798612d07c93d9a4e0ef2f2
parent085c1f8f60c8ae9e354d470ea8c7831982b026ad (diff)
downloadandroid-node-v8-610ac7d8581012e627a4f4b67450b423ddbda415.tar.gz
android-node-v8-610ac7d8581012e627a4f4b67450b423ddbda415.tar.bz2
android-node-v8-610ac7d8581012e627a4f4b67450b423ddbda415.zip
test: increase coverage of internal/socket_list
PR-URL: https://github.com/nodejs/node/pull/12066 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--test/parallel/test-internal-socket-list-receive.js1
-rw-r--r--test/parallel/test-internal-socket-list-send.js22
2 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-internal-socket-list-receive.js b/test/parallel/test-internal-socket-list-receive.js
index 5315adbfd4..c0eb223719 100644
--- a/test/parallel/test-internal-socket-list-receive.js
+++ b/test/parallel/test-internal-socket-list-receive.js
@@ -17,6 +17,7 @@ const key = 'test-key';
const list = new SocketListReceive(child, key);
list.child.emit('internalMessage', { key, cmd: 'NODE_SOCKET_NOTIFY_CLOSE' });
+ list.child.emit('internalMessage', { key, cmd: 'NODE_SOCKET_GET_COUNT' });
}
// Verify that a "NODE_SOCKET_ALL_CLOSED" message will be sent.
diff --git a/test/parallel/test-internal-socket-list-send.js b/test/parallel/test-internal-socket-list-send.js
index a5020a431c..10413bfdbc 100644
--- a/test/parallel/test-internal-socket-list-send.js
+++ b/test/parallel/test-internal-socket-list-send.js
@@ -112,3 +112,25 @@ const key = 'test-key';
assert.strictEqual(child.listenerCount('disconnect'), 0);
}));
}
+
+// Verify that an error will be received in callback when child is
+// disconnected after sending a message and before getting the reply.
+{
+ const count = 1;
+ const child = Object.assign(new EventEmitter(), {
+ connected: true,
+ send: function(msg) {
+ process.nextTick(() => {
+ this.emit('disconnect');
+ this.emit('internalMessage', { key, count, cmd: 'NODE_SOCKET_COUNT' });
+ });
+ }
+ });
+
+ const list = new SocketListSend(child, key);
+
+ list.getConnections(common.mustCall((err, msg) => {
+ assert.strictEqual(err.message, 'child closed before reply');
+ assert.strictEqual(child.listenerCount('internalMessage'), 0);
+ }));
+}