527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
# File 'src/ruby/pb/test/client.rb', line 527
def status_code_and_message
message = "test status method"
code = GRPC::Core::StatusCodes::UNKNOWN
payload = Payload.new(type: :COMPRESSABLE, body: nulls(1))
echo_status = EchoStatus.new(code: code, message: message)
req = SimpleRequest.new(response_type: :COMPRESSABLE,
response_size: 1,
payload: payload,
response_status: echo_status)
seen_correct_exception = false
begin
resp = @stub.unary_call(req)
rescue GRPC::Unknown => e
if e.details != message
fail AssertionError,
"Expected message #{message}. Received: #{e.details}"
end
seen_correct_exception = true
rescue Exception => e
fail AssertionError, "Expected BadStatus. Received: #{e.inspect}"
end
if not seen_correct_exception
fail AssertionError, "Did not see expected status from UnaryCall"
end
req_cls, p_cls = StreamingOutputCallRequest, ResponseParameters
duplex_req = req_cls.new(payload: Payload.new(body: nulls(1)),
response_type: :COMPRESSABLE,
response_parameters: [p_cls.new(size: 1)],
response_status: echo_status)
seen_correct_exception = false
begin
resp = @stub.full_duplex_call([duplex_req])
resp.each { |r| }
rescue GRPC::Unknown => e
if e.details != message
fail AssertionError,
"Expected message #{message}. Received: #{e.details}"
end
seen_correct_exception = true
rescue Exception => e
fail AssertionError, "Expected BadStatus. Received: #{e.inspect}"
end
if not seen_correct_exception
fail AssertionError, "Did not see expected status from FullDuplexCall"
end
end
|