diff options
author | 2015-07-17 13:54:36 -0700 | |
---|---|---|
committer | 2015-07-17 13:54:36 -0700 | |
commit | 068e320ed17d2eb3c2ccd82ee3bc5e8b7b783544 (patch) | |
tree | 680727383b2ab1a117bc9094983914be7c7db155 | |
parent | 048fc2f04fc5802621eb4703a14f49625265f498 (diff) | |
parent | 560b82c459d12b8aed88efc5bbee4ff0f6ebfe61 (diff) |
Merge pull request #2486 from murgatroid99/node_error_status_test
Add tests for translating server handler errors to status objects
-rw-r--r-- | src/node/test/surface_test.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js index 8d1f99aaee..125957277f 100644 --- a/src/node/test/surface_test.js +++ b/src/node/test/surface_test.js @@ -418,6 +418,48 @@ describe('Other conditions', function() { }); }); }); + describe('Error object should contain the status', function() { + it('for a unary call', function(done) { + client.unary({error: true}, function(err, data) { + assert(err); + assert.strictEqual(err.code, grpc.status.UNKNOWN); + assert.strictEqual(err.message, 'Requested error'); + done(); + }); + }); + it('for a client stream call', function(done) { + var call = client.clientStream(function(err, data) { + assert(err); + assert.strictEqual(err.code, grpc.status.UNKNOWN); + assert.strictEqual(err.message, 'Requested error'); + done(); + }); + call.write({error: false}); + call.write({error: true}); + call.end(); + }); + it('for a server stream call', function(done) { + var call = client.serverStream({error: true}); + call.on('data', function(){}); + call.on('error', function(error) { + assert.strictEqual(error.code, grpc.status.UNKNOWN); + assert.strictEqual(error.message, 'Requested error'); + done(); + }); + }); + it('for a bidi stream call', function(done) { + var call = client.bidiStream(); + call.write({error: false}); + call.write({error: true}); + call.end(); + call.on('data', function(){}); + call.on('error', function(error) { + assert.strictEqual(error.code, grpc.status.UNKNOWN); + assert.strictEqual(error.message, 'Requested error'); + done(); + }); + }); + }); }); describe('Cancelling surface client', function() { var client; |