Skip to content

Commit

Permalink
test(grpc): change server port
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Nov 9, 2024
1 parent 03346c7 commit 0662d18
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { join } from 'path';

export const grpcServer = {
url: 'localhost:6569',
services: [
{
protoPath: join(__dirname, '../../../proto/hello_world.proto'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join } from 'path';
export const grpc = {
services: [
{
url: 'localhost:6565',
url: 'localhost:6575',
protoPath: join(__dirname, '../../../proto/helloworld.proto'),
package: 'helloworld',
clientOptions: {
Expand All @@ -14,6 +14,7 @@ export const grpc = {
}

export const grpcServer = {
url: 'localhost:6575',
services: [
{
protoPath: join(__dirname, '../../../proto/hero.proto'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ export namespace hero {
id?: number;
name?: string;
}

export interface HeroService2 {
findOne2(data: HeroById, metadata?: Metadata): Promise<Hero>;
}
export interface HeroService2Client {
findOne2(options?: IClientOptions): IClientUnaryService<HeroById, Hero>;
}
}

export namespace helloworld {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export class HeroService implements hero.HeroService {
assert(metadata, 'should get metadata');

const rpcDefinition = metadata.get('rpc.definition');
assert(rpcDefinition[0] === 'hero.HeroService', 'should get rpc.definition');
assert(rpcDefinition[0] === 'hero.HeroService', `should get rpc.definition, but got "${rpcDefinition}"`);

const rpcMethod = metadata.get('rpc.method');
assert(rpcMethod[0] === 'findOne', 'should get rpc.method');
assert(rpcMethod[0] === 'FindOne', `should get rpc.method, but got "${rpcMethod[0]}"`);

const rpcMethodType = metadata.get('rpc.method.type');
assert(rpcMethodType[0] === 'unary', 'should get rpc.method.type');
assert(rpcMethodType[0] === 'unary', `should get rpc.method.type, but got "${rpcMethodType[0]}"`);

const result = await this.greeterService.sayHello().sendMessage({
name: 'harry'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { join } from 'path';

export const grpcServer = {
url: 'localhost:6568',
services: [
{
protoPath: join(__dirname, '../../../proto/math.proto'),
Expand Down
6 changes: 3 additions & 3 deletions packages/grpc/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('/test/index.test.ts', function () {
const opts = {
package: 'hero',
protoPath: join(__dirname, 'fixtures/proto/hero.proto'),
url: 'localhost:6565'
url: 'localhost:6575'
}
const service = await createGRPCConsumer<hero.HeroServiceClient>({ ...opts, });
const result = await service.findOne().sendMessage({ id: 123 });
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('/test/index.test.ts', function () {
const service = await createGRPCConsumer<math.MathClient>({
package: 'math',
protoPath: join(__dirname, 'fixtures/proto/math.proto'),
url: 'localhost:6565'
url: 'localhost:6568'
});

// 使用发送消息的写法
Expand Down Expand Up @@ -260,7 +260,7 @@ describe('/test/index.test.ts', function () {
const service = await createGRPCConsumer<hello.world.GreeterClient>({
package: 'hello.world',
protoPath: join(__dirname, 'fixtures/proto/hello_world.proto'),
url: 'localhost:6565'
url: 'localhost:6569'
});

const result = await service.sayHello().sendMessage({
Expand Down

0 comments on commit 0662d18

Please sign in to comment.