From da0032df8f27bc809020e622c37acace1bb638da Mon Sep 17 00:00:00 2001 From: waiting <1661926154@qq.com> Date: Tue, 12 Nov 2024 18:36:00 +0800 Subject: [PATCH] test(grpc): revert case base-app-stream --- .../base-app-stream/src/provider/math.ts | 56 +------------------ 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/packages/grpc/test/fixtures/base-app-stream/src/provider/math.ts b/packages/grpc/test/fixtures/base-app-stream/src/provider/math.ts index 602c6f72c02..0a493d3a36a 100644 --- a/packages/grpc/test/fixtures/base-app-stream/src/provider/math.ts +++ b/packages/grpc/test/fixtures/base-app-stream/src/provider/math.ts @@ -1,6 +1,4 @@ -import * as assert from 'assert'; -import { GrpcMethod, GrpcStreamTypeEnum, Inject, MSProviderType, Provide, Provider } from '@midwayjs/core'; -import { Context } from '../../../../../src'; +import { GrpcMethod, GrpcStreamTypeEnum, MSProviderType, Provide, Provider } from '@midwayjs/core'; import { math } from '../interface'; import { Metadata } from '@grpc/grpc-js'; @@ -10,26 +8,10 @@ import { Metadata } from '@grpc/grpc-js'; @Provider(MSProviderType.GRPC, { package: 'math' }) export class Math implements math.Math { - @Inject() - ctx: Context; - sumDataList = []; @GrpcMethod() async add(data: math.AddArgs): Promise { - assert(this.ctx, 'should get context'); - const { metadata } = this.ctx; - assert(metadata, 'should get metadata'); - - const rpcDefinition = metadata.get('rpc.definition'); - assert(rpcDefinition[0] === 'math.Math', `should get rpc.definition, but got "${rpcDefinition}"`); - - const rpcMethod = metadata.get('rpc.method'); - assert(rpcMethod[0] === 'Add', `should get rpc.method, but got "${rpcMethod[0]}"`); - - const rpcMethodType = metadata.get('rpc.method.type'); - assert(rpcMethodType[0] === 'unary', `should get rpc.method.type, but got "${rpcMethodType[0]}"`); - return { num: data.num + 2, } @@ -37,18 +19,6 @@ export class Math implements math.Math { @GrpcMethod({type: GrpcStreamTypeEnum.DUPLEX, onEnd: 'duplexEnd' }) async addMore(message: math.AddArgs) { - const { metadata } = this.ctx; - assert(metadata, 'should get metadata'); - - const rpcDefinition = metadata.get('rpc.definition'); - assert(rpcDefinition[0] === 'math.Math', `should get rpc.definition, but got "${rpcDefinition}"`); - - const rpcMethod = metadata.get('rpc.method'); - assert(rpcMethod[0] === 'AddMore', `should get rpc.method, but got "${rpcMethod[0]}"`); - - const rpcMethodType = metadata.get('rpc.method.type'); - assert(rpcMethodType[0] === 'bidi', `should get rpc.method.type, but got "${rpcMethodType[0]}"`); - this.ctx.write({ id: message.id, num: message.num + 10, @@ -61,18 +31,6 @@ export class Math implements math.Math { @GrpcMethod({type: GrpcStreamTypeEnum.WRITEABLE }) async sumMany(args: math.AddArgs) { - const { metadata } = this.ctx; - assert(metadata, 'should get metadata'); - - const rpcDefinition = metadata.get('rpc.definition'); - assert(rpcDefinition[0] === 'math.Math', `should get rpc.definition, but got "${rpcDefinition}"`); - - const rpcMethod = metadata.get('rpc.method'); - assert(rpcMethod[0] === 'SumMany', `should get rpc.method, but got "${rpcMethod[0]}"`); - - const rpcMethodType = metadata.get('rpc.method.type'); - assert(rpcMethodType[0] === 'server', `should get rpc.method.type, but got "${rpcMethodType[0]}"`); - this.ctx.write({ num: 1 + args.num }); @@ -92,18 +50,6 @@ export class Math implements math.Math { @GrpcMethod({type: GrpcStreamTypeEnum.READABLE, onEnd: 'sumEnd' }) async addMany(data: math.Num) { - const { metadata } = this.ctx; - assert(metadata, 'should get metadata'); - - const rpcDefinition = metadata.get('rpc.definition'); - assert(rpcDefinition[0] === 'math.Math', `should get rpc.definition, but got "${rpcDefinition}"`); - - const rpcMethod = metadata.get('rpc.method'); - assert(rpcMethod[0] === 'AddMany', `should get rpc.method, but got "${rpcMethod[0]}"`); - - const rpcMethodType = metadata.get('rpc.method.type'); - assert(rpcMethodType[0] === 'client', `should get rpc.method.type, but got "${rpcMethodType[0]}"`); - this.sumDataList.push(data); }