Refactored other tests

pull/224/head
murgatroid99 10 years ago
parent 4b962f72d3
commit d485b13fb8
  1. 21
      src/node/test/end_to_end_test.js
  2. 13
      src/node/test/server_test.js

@ -56,14 +56,21 @@ function multiDone(done, count) {
}
describe('end-to-end', function() {
var server;
var channel;
before(function() {
server = new grpc.Server();
var port_num = server.addHttp2Port('0.0.0.0:0');
server.start();
channel = new grpc.Channel('localhost:' + port_num);
});
after(function() {
server.shutdown();
});
it('should start and end a request without error', function(complete) {
var server = new grpc.Server();
var done = multiDone(function() {
complete();
server.shutdown();
}, 2);
var port_num = server.addHttp2Port('0.0.0.0:0');
var channel = new grpc.Channel('localhost:' + port_num);
var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 3);
var status_text = 'xyz';
@ -81,7 +88,6 @@ describe('end-to-end', function() {
done();
}, 0);
server.start();
server.requestCall(function(event) {
assert.strictEqual(event.type, grpc.completionType.SERVER_RPC_NEW);
var server_call = event.call;
@ -109,13 +115,10 @@ describe('end-to-end', function() {
it('should send and receive data without error', function(complete) {
var req_text = 'client_request';
var reply_text = 'server_response';
var server = new grpc.Server();
var done = multiDone(function() {
complete();
server.shutdown();
}, 6);
var port_num = server.addHttp2Port('0.0.0.0:0');
var channel = new grpc.Channel('localhost:' + port_num);
var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 3);
var status_text = 'success';
@ -151,8 +154,6 @@ describe('end-to-end', function() {
assert.strictEqual(event.data.toString(), reply_text);
done();
});
server.start();
server.requestCall(function(event) {
assert.strictEqual(event.type, grpc.completionType.SERVER_RPC_NEW);
var server_call = event.call;

@ -65,17 +65,22 @@ function echoHandler(stream) {
}
describe('echo server', function() {
it('should echo inputs as responses', function(done) {
done = multiDone(done, 4);
var server = new Server();
var server;
var channel;
before(function() {
server = new Server();
var port_num = server.bind('[::]:0');
server.register('echo', echoHandler);
server.start();
channel = new grpc.Channel('localhost:' + port_num);
});
it('should echo inputs as responses', function(done) {
done = multiDone(done, 4);
var req_text = 'echo test string';
var status_text = 'OK';
var channel = new grpc.Channel('localhost:' + port_num);
var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 3);
var call = new grpc.Call(channel,

Loading…
Cancel
Save