Permalink
Browse files

[testcase] add close handling to requester fixture

  • Loading branch information...
1 parent b4dc207 commit 1afc293eef5c52c860aa3dda74ee24dcbbf09a05 @AndreasMadsen committed Feb 7, 2012
Showing with 21 additions and 1 deletion.
  1. +21 −1 test/fixture/requester.js
View
@@ -20,6 +20,11 @@ requester.on('connect', function (remote) {
});
});
+var isClosed = false;
+requester.on('close', function () {
+ isClosed = true;
+});
+
process.on('message', function connectHandle (msg) {
if (msg.what === 'connect') {
process.removeListener('message', connectHandle);
@@ -29,5 +34,20 @@ process.on('message', function connectHandle (msg) {
} else if (process.argv[2] === 'TCP') {
requester.connect('TCP', common.PORT);
}
+
}
-});
+});
+
+process.on('message', function closeHandle (msg) {
+ if (msg.what === 'closed') {
+ process.removeListener('message', closeHandle);
+
+ if (isClosed) {
+ process.send({what: 'closed', online: requester.online, error: null});
+ } else {
+ requester.on('close', function () {
+ process.send({what: 'closed', online: requester.online, error: null});
+ });
+ }
+ }
+});

0 comments on commit 1afc293

Please sign in to comment.