diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-05-26 17:53:06 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-06-03 23:08:24 +0200 |
commit | 1dc3272bb9c2ecd442efd5b978a852a7da31c1e9 (patch) | |
tree | d835fa61e0503a8b5c4405c03003085129c2d0fe /test/async-hooks/test-tcpwrap.js | |
parent | 8741e3c7501cbe66696bd3fad4a0a923e76ba11d (diff) | |
download | android-node-v8-1dc3272bb9c2ecd442efd5b978a852a7da31c1e9.tar.gz android-node-v8-1dc3272bb9c2ecd442efd5b978a852a7da31c1e9.tar.bz2 android-node-v8-1dc3272bb9c2ecd442efd5b978a852a7da31c1e9.zip |
test: improve async hooks test error messages
Improve error messages in the async hooks tests, mostly by removing
unhelpful `message` parameters for assertions.
PR-URL: https://github.com/nodejs/node/pull/13243
Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'test/async-hooks/test-tcpwrap.js')
-rw-r--r-- | test/async-hooks/test-tcpwrap.js | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/test/async-hooks/test-tcpwrap.js b/test/async-hooks/test-tcpwrap.js index 0827779229..bdb45b47a3 100644 --- a/test/async-hooks/test-tcpwrap.js +++ b/test/async-hooks/test-tcpwrap.js @@ -29,16 +29,12 @@ const server = net server.listen(common.PORT); const tcps = hooks.activitiesOfTypes('TCPWRAP'); const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP'); - assert.strictEqual( - tcps.length, 1, - 'one TCPWRAP created synchronously when calling server.listen'); - assert.strictEqual( - tcpconnects.length, 0, - 'no TCPCONNECTWRAP created synchronously when calling server.listen'); + assert.strictEqual(tcps.length, 1); + assert.strictEqual(tcpconnects.length, 0); tcp1 = tcps[0]; - assert.strictEqual(tcp1.type, 'TCPWRAP', 'tcp wrap'); - assert.strictEqual(typeof tcp1.uid, 'number', 'uid is a number'); - assert.strictEqual(typeof tcp1.triggerId, 'number', 'triggerId is a number'); + assert.strictEqual(tcp1.type, 'TCPWRAP'); + assert.strictEqual(typeof tcp1.uid, 'number'); + assert.strictEqual(typeof tcp1.triggerId, 'number'); checkInvocations(tcp1, { init: 1 }, 'when calling server.listen'); } @@ -48,30 +44,24 @@ const server = net { port: server.address().port, host: server.address().address }, common.mustCall(onconnected)); const tcps = hooks.activitiesOfTypes('TCPWRAP'); - assert.strictEqual( - tcps.length, 2, - '2 TCPWRAPs present when client is connecting'); + assert.strictEqual(tcps.length, 2); process.nextTick(() => { const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP'); - assert.strictEqual( - tcpconnects.length, 1, - '1 TCPCONNECTWRAP present when client is connecting'); + assert.strictEqual(tcpconnects.length, 1); }); tcp2 = tcps[1]; - assert.strictEqual(tcps.length, 2, - '2 TCPWRAP present when client is connecting'); - assert.strictEqual(tcp2.type, 'TCPWRAP', 'tcp wrap'); - assert.strictEqual(typeof tcp2.uid, 'number', 'uid is a number'); - assert.strictEqual(typeof tcp2.triggerId, 'number', 'triggerId is a number'); + assert.strictEqual(tcps.length, 2); + assert.strictEqual(tcp2.type, 'TCPWRAP'); + assert.strictEqual(typeof tcp2.uid, 'number'); + assert.strictEqual(typeof tcp2.triggerId, 'number'); checkInvocations(tcp1, { init: 1 }, 'tcp1 when client is connecting'); checkInvocations(tcp2, { init: 1 }, 'tcp2 when client is connecting'); } function onlistening() { - assert.strictEqual(hooks.activitiesOfTypes('TCPWRAP').length, 2, - 'two TCPWRAPs when server is listening'); + assert.strictEqual(hooks.activitiesOfTypes('TCPWRAP').length, 2); } // Depending on timing we see client: onconnected or server: onconnection first @@ -92,14 +82,11 @@ function ontcpConnection(serverConnection) { // only focusing on TCPCONNECTWRAP here const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP'); - assert.strictEqual( - tcpconnects.length, 1, - 'one TCPCONNECTWRAP present on tcp connection'); + assert.strictEqual(tcpconnects.length, 1); tcpconnect = tcpconnects[0]; - assert.strictEqual(tcpconnect.type, 'TCPCONNECTWRAP', 'tcpconnect wrap'); - assert.strictEqual(typeof tcpconnect.uid, 'number', 'uid is a number'); - assert.strictEqual(typeof tcpconnect.triggerId, - 'number', 'triggerId is a number'); + assert.strictEqual(tcpconnect.type, 'TCPCONNECTWRAP'); + assert.strictEqual(typeof tcpconnect.uid, 'number'); + assert.strictEqual(typeof tcpconnect.triggerId, 'number'); // When client receives connection first ('onconnected'), we 'before' has // been invoked at this point already, otherwise it only was 'init'ed const expected = serverConnection ? { init: 1 } : { init: 1, before: 1 }; @@ -125,16 +112,12 @@ function onconnection(c) { const tcps = hooks.activitiesOfTypes([ 'TCPWRAP' ]); const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP'); - assert.strictEqual( - tcps.length, 3, - '3 TCPWRAPs present when server receives connection'); - assert.strictEqual( - tcpconnects.length, 1, - 'one TCPCONNECTWRAP present when server receives connection'); + assert.strictEqual(tcps.length, 3); + assert.strictEqual(tcpconnects.length, 1); tcp3 = tcps[2]; - assert.strictEqual(tcp3.type, 'TCPWRAP', 'tcp wrap'); - assert.strictEqual(typeof tcp3.uid, 'number', 'uid is a number'); - assert.strictEqual(typeof tcp3.triggerId, 'number', 'triggerId is a number'); + assert.strictEqual(tcp3.type, 'TCPWRAP'); + assert.strictEqual(typeof tcp3.uid, 'number'); + assert.strictEqual(typeof tcp3.triggerId, 'number'); checkInvocations(tcp1, { init: 1, before: 1 }, 'tcp1 when server receives connection'); |