aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/test
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-04-27 14:55:13 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-04-27 14:55:13 -0700
commit92b8decaff5dae78531af309b241babe03c54f01 (patch)
treee2c768e5938e482931a4b161f0e9e7b8898de7cf /src/node/test
parent8658b1786628c8cb10ea0a74e7a11733f66a20ab (diff)
Make Node servers warn instead of fail when a method is missing a handler
Diffstat (limited to 'src/node/test')
-rw-r--r--src/node/test/surface_test.js56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
index b96e8e487c..d8b36dc55c 100644
--- a/src/node/test/surface_test.js
+++ b/src/node/test/surface_test.js
@@ -143,21 +143,59 @@ describe('Server.prototype.addProtoService', function() {
server.addProtoService(mathService, dummyImpls);
});
});
- it('Should fail with missing handlers', function() {
- assert.throws(function() {
- server.addProtoService(mathService, {
- 'div': function() {},
- 'divMany': function() {},
- 'fib': function() {}
- });
- }, /math.Math.Sum/);
- });
it('Should fail if the server has been started', function() {
server.start();
assert.throws(function() {
server.addProtoService(mathService, dummyImpls);
});
});
+ describe('Default handlers', function() {
+ var client;
+ beforeEach(function() {
+ server.addProtoService(mathService, {});
+ var port = server.bind('localhost:0', server_insecure_creds);
+ var Client = surface_client.makeProtobufClientConstructor(mathService);
+ client = new Client('localhost:' + port,
+ grpc.credentials.createInsecure());
+ server.start();
+ });
+ it('should respond to a unary call with UNIMPLEMENTED', function(done) {
+ client.div({divisor: 4, dividend: 3}, function(error, response) {
+ assert(error);
+ assert.strictEqual(error.code, grpc.status.UNIMPLEMENTED);
+ done();
+ });
+ });
+ it('should respond to a client stream with UNIMPLEMENTED', function(done) {
+ var call = client.sum(function(error, respones) {
+ assert(error);
+ assert.strictEqual(error.code, grpc.status.UNIMPLEMENTED);
+ done();
+ });
+ call.end();
+ });
+ it('should respond to a server stream with UNIMPLEMENTED', function(done) {
+ var call = client.fib({limit: 5});
+ call.on('data', function(value) {
+ assert.fail('No messages expected');
+ });
+ call.on('status', function(status) {
+ assert.strictEqual(status.code, grpc.status.UNIMPLEMENTED);
+ done();
+ });
+ });
+ it('should respond to a bidi call with UNIMPLEMENTED', function(done) {
+ var call = client.divMany();
+ call.on('data', function(value) {
+ assert.fail('No messages expected');
+ });
+ call.on('status', function(status) {
+ assert.strictEqual(status.code, grpc.status.UNIMPLEMENTED);
+ done();
+ });
+ call.end();
+ });
+ });
});
describe('Client constructor building', function() {
var illegal_service_attrs = {