mirror of https://github.com/grpc/grpc-dart.git
Fix a typo on the inner invoker parameters (#492)
This commit is contained in:
parent
f23070ee85
commit
f5508d9801
|
|
@ -60,7 +60,7 @@ regenerate these stubs using protobuf compiler plugin version 19.2.0 or newer.
|
|||
ResponseStream<R> $createStreamingCall<Q, R>(
|
||||
ClientMethod<Q, R> method, Stream<Q> requests,
|
||||
{CallOptions? options}) {
|
||||
var invoker = (method, request, options) =>
|
||||
var invoker = (method, requests, options) =>
|
||||
ResponseStream<R>(_channel.createCall<Q, R>(method, requests, options));
|
||||
|
||||
for (final interceptor in _interceptors.reversed) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:grpc/grpc.dart';
|
||||
import 'package:grpc/src/client/interceptor.dart';
|
||||
import 'package:http2/transport.dart';
|
||||
|
|
@ -44,7 +46,11 @@ class FakeInterceptor implements ClientInterceptor {
|
|||
ClientStreamingInvoker<Q, R> invoker) {
|
||||
_invocations.add(InterceptorInvocation(_id, _unary, ++_streaming));
|
||||
|
||||
return invoker(method, requests, _inject(options));
|
||||
final requestStream = _id > 10
|
||||
? requests.cast<int>().map((req) => req * _id).cast<Q>()
|
||||
: requests;
|
||||
|
||||
return invoker(method, requestStream, _inject(options));
|
||||
}
|
||||
|
||||
CallOptions _inject(CallOptions options) {
|
||||
|
|
@ -206,4 +212,43 @@ void main() {
|
|||
harness.tearDown();
|
||||
FakeInterceptor.tearDown();
|
||||
});
|
||||
|
||||
test('streaming interceptors with request stream operation', () async {
|
||||
const ids = [21, 73, 37];
|
||||
|
||||
final harness = ClientHarness()
|
||||
..interceptors = ids.map((e) => FakeInterceptor(e))
|
||||
..setUp();
|
||||
|
||||
const requests = [1, 15, 7];
|
||||
const multiplier = 21 * 73 * 37;
|
||||
const responses = [1 * multiplier, 15 * multiplier, 7 * multiplier];
|
||||
|
||||
var index = 0;
|
||||
|
||||
void handleRequest(StreamMessage message) {
|
||||
final data = validateDataMessage(message);
|
||||
final request = mockDecode(data.data);
|
||||
if (index++ == 0) {
|
||||
harness.sendResponseHeader();
|
||||
}
|
||||
harness.sendResponseValue(request);
|
||||
}
|
||||
|
||||
void handleDone() {
|
||||
harness.sendResponseTrailer();
|
||||
}
|
||||
|
||||
await harness.runTest(
|
||||
clientCall:
|
||||
harness.client.bidirectional(Stream.fromIterable(requests)).toList(),
|
||||
expectedResult: responses,
|
||||
expectedPath: '/Test/Bidirectional',
|
||||
serverHandlers: [handleRequest, handleRequest, handleRequest],
|
||||
doneHandler: handleDone,
|
||||
);
|
||||
|
||||
harness.tearDown();
|
||||
FakeInterceptor.tearDown();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue