mirror of https://github.com/grpc/grpc-node.git
grpc-js: Simplify client.waitForReady tests. Refs #1352
No need to add a service to the server to test the client.
This commit is contained in:
parent
615a3c65b1
commit
7e381f7f2a
|
|
@ -15,17 +15,11 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Allow `any` data type for testing runtime type checking.
|
|
||||||
// tslint:disable no-any
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
import * as grpc from '../src';
|
import * as grpc from '../src';
|
||||||
import { Server, ServerCredentials } from '../src';
|
import { Server, ServerCredentials } from '../src';
|
||||||
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
import { Client } from '../src';
|
||||||
import { sendUnaryData, ServerUnaryCall } from '../src/server-call';
|
|
||||||
|
|
||||||
import { loadProtoFile } from './common';
|
|
||||||
import { ConnectivityState } from '../src/channel';
|
import { ConnectivityState } from '../src/channel';
|
||||||
|
|
||||||
const clientInsecureCreds = grpc.credentials.createInsecure();
|
const clientInsecureCreds = grpc.credentials.createInsecure();
|
||||||
|
|
@ -33,13 +27,9 @@ const serverInsecureCreds = ServerCredentials.createInsecure();
|
||||||
|
|
||||||
describe('Client', () => {
|
describe('Client', () => {
|
||||||
let server: Server;
|
let server: Server;
|
||||||
let client: ServiceClient;
|
let client: Client;
|
||||||
|
|
||||||
before(done => {
|
before(done => {
|
||||||
const protoFile = path.join(__dirname, 'fixtures', 'echo_service.proto');
|
|
||||||
const echoService = loadProtoFile(protoFile)
|
|
||||||
.EchoService as ServiceClientConstructor;
|
|
||||||
|
|
||||||
server = new Server();
|
server = new Server();
|
||||||
|
|
||||||
server.bindAsync(
|
server.bindAsync(
|
||||||
|
|
@ -47,7 +37,7 @@ describe('Client', () => {
|
||||||
serverInsecureCreds,
|
serverInsecureCreds,
|
||||||
(err, port) => {
|
(err, port) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
client = new echoService(
|
client = new Client(
|
||||||
`localhost:${port}`,
|
`localhost:${port}`,
|
||||||
clientInsecureCreds
|
clientInsecureCreds
|
||||||
);
|
);
|
||||||
|
|
@ -62,7 +52,7 @@ describe('Client', () => {
|
||||||
server.tryShutdown(done);
|
server.tryShutdown(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the waitForReady callback only once when channel connectivity state is READY', done => {
|
it('should call the waitForReady callback only once, when channel connectivity state is READY', done => {
|
||||||
const deadline = Date.now() + 100;
|
const deadline = Date.now() + 100;
|
||||||
let calledTimes = 0;
|
let calledTimes = 0;
|
||||||
client.waitForReady(deadline, err => {
|
client.waitForReady(deadline, err => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue