diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/node/interop/interop_client.js | 43 | ||||
-rw-r--r-- | src/node/test/interop_sanity_test.js | 8 |
2 files changed, 49 insertions, 2 deletions
diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js index 9306317b68..ce18f77fe7 100644 --- a/src/node/interop/interop_client.js +++ b/src/node/interop/interop_client.js @@ -199,7 +199,6 @@ function pingPong(client, done) { /** * Run the empty_stream test. - * NOTE: This does not work, but should with the new invoke API * @param {Client} client The client to test against * @param {function} done Callback to call when the test is completed. Included * primarily for use with mocha @@ -219,6 +218,44 @@ function emptyStream(client, done) { } /** + * Run the cancel_after_begin test. + * @param {Client} client The client to test against + * @param {function} done Callback to call when the test is completed. Included + * primarily for use with mocha + */ +function cancelAfterBegin(client, done) { + var call = client.streamingInputCall(function(err, resp) { + assert.strictEqual(err.code, grpc.status.CANCELLED); + done(); + }); + call.cancel(); +} + +/** + * Run the cancel_after_first_response test. + * @param {Client} client The client to test against + * @param {function} done Callback to call when the test is completed. Included + * primarily for use with mocha + */ +function cancelAfterFirstResponse(client, done) { + var call = client.fullDuplexCall(); + call.write({ + response_type: testProto.PayloadType.COMPRESSABLE, + response_parameters: [ + {size: 31415} + ], + payload: {body: zeroBuffer(27182)} + }); + call.on('data', function(data) { + call.cancel(); + }); + call.on('status', function(status) { + assert.strictEqual(status.code, grpc.status.CANCELLED); + done(); + }); +} + +/** * Map from test case names to test functions */ var test_cases = { @@ -227,7 +264,9 @@ var test_cases = { client_streaming: clientStreaming, server_streaming: serverStreaming, ping_pong: pingPong, - empty_stream: emptyStream + empty_stream: emptyStream, + cancel_after_begin: cancelAfterBegin, + cancel_after_first_response: cancelAfterFirstResponse }; /** diff --git a/src/node/test/interop_sanity_test.js b/src/node/test/interop_sanity_test.js index 6cc7d444cd..7ecaad833d 100644 --- a/src/node/test/interop_sanity_test.js +++ b/src/node/test/interop_sanity_test.js @@ -71,4 +71,12 @@ describe('Interop tests', function() { it('should pass empty_stream', function(done) { interop_client.runTest(port, name_override, 'empty_stream', true, done); }); + it('should pass cancel_after_begin', function(done) { + interop_client.runTest(port, name_override, 'cancel_after_begin', true, + done); + }); + it('should pass cancel_after_first_response', function(done) { + interop_client.runTest(port, name_override, 'cancel_after_first_response', + true, done); + }); }); |