@@ -2099,6 +2099,10 @@ func (t *myTap) handle(ctx context.Context, info *tap.Info) (context.Context, er
20992099 switch info .FullMethodName {
21002100 case "/grpc.testing.TestService/EmptyCall" :
21012101 t .cnt ++
2102+
2103+ if vals := info .Header .Get ("return-error" ); len (vals ) > 0 && vals [0 ] == "true" {
2104+ return nil , status .Errorf (codes .Unknown , "tap error" )
2105+ }
21022106 case "/grpc.testing.TestService/UnaryCall" :
21032107 return nil , fmt .Errorf ("tap error" )
21042108 case "/grpc.testing.TestService/FullDuplexCall" :
@@ -2120,13 +2124,28 @@ func testTap(t *testing.T, e env) {
21202124 tc := testgrpc .NewTestServiceClient (cc )
21212125 ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
21222126 defer cancel ()
2127+
21232128 if _ , err := tc .EmptyCall (ctx , & testpb.Empty {}); err != nil {
21242129 t .Fatalf ("TestService/EmptyCall(_, _) = _, %v, want _, <nil>" , err )
21252130 }
21262131 if ttap .cnt != 1 {
21272132 t .Fatalf ("Get the count in ttap %d, want 1" , ttap .cnt )
21282133 }
21292134
2135+ if _ , err := tc .EmptyCall (metadata .AppendToOutgoingContext (ctx , "return-error" , "false" ), & testpb.Empty {}); err != nil {
2136+ t .Fatalf ("TestService/EmptyCall(_, _) = _, %v, want _, <nil>" , err )
2137+ }
2138+ if ttap .cnt != 2 {
2139+ t .Fatalf ("Get the count in ttap %d, want 2" , ttap .cnt )
2140+ }
2141+
2142+ if _ , err := tc .EmptyCall (metadata .AppendToOutgoingContext (ctx , "return-error" , "true" ), & testpb.Empty {}); status .Code (err ) != codes .Unknown {
2143+ t .Fatalf ("TestService/EmptyCall(_, _) = _, %v, want _, %s" , err , codes .Unknown )
2144+ }
2145+ if ttap .cnt != 3 {
2146+ t .Fatalf ("Get the count in ttap %d, want 3" , ttap .cnt )
2147+ }
2148+
21302149 payload , err := newPayload (testpb .PayloadType_COMPRESSABLE , 31 )
21312150 if err != nil {
21322151 t .Fatal (err )
0 commit comments