Added cancellation interop tests to Node interop client

pull/292/head
murgatroid99 10 years ago
parent 3726a4d477
commit bca2f955ba
  1. 43
      src/node/interop/interop_client.js
  2. 8
      src/node/test/interop_sanity_test.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
@ -218,6 +217,44 @@ function emptyStream(client, done) {
call.end();
}
/**
* 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
*/
@ -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
};
/**

@ -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);
});
});

Loading…
Cancel
Save