@@ -2155,44 +2155,34 @@ func testTap(t *testing.T, e env) {
21552155}
21562156
21572157func (s ) TestTapStatusDetails (t * testing.T ) {
2158- wantDetails := & testpb.Empty {}
2159- st := status .New (codes .ResourceExhausted , "rate limit exceeded" )
2160- st , err := st .WithDetails (wantDetails )
2161- if err != nil {
2162- t .Fatalf ("status.WithDetails() failed: %v" , err )
2163- }
2164-
2165- tapHandler := func (_ context.Context , _ * tap.Info ) (context.Context , error ) {
2158+ tapHandler := func (context.Context , * tap.Info ) (context.Context , error ) {
21662159 // Return error with details for all RPCs.
2160+ wantDetails := & testpb.Empty {}
2161+ st := status .New (codes .ResourceExhausted , "rate limit exceeded" )
2162+ st , err := st .WithDetails (wantDetails )
2163+ if err != nil {
2164+ t .Fatalf ("status.WithDetails() failed: %v" , err )
2165+ }
21672166 return nil , st .Err ()
21682167 }
21692168
2170- ss := & stubserver.StubServer {
2171- EmptyCallF : func (_ context.Context , _ * testpb.Empty ) (* testpb.Empty , error ) {
2172- // This should never be called since TAP handler rejects the RPC.
2173- return & testpb.Empty {}, nil
2174- },
2175- }
2176- sopts := []grpc.ServerOption {grpc .InTapHandle (tapHandler )}
2177- if err := ss .Start (sopts ); err != nil {
2178- t .Fatalf ("Error starting server: %v" , err )
2179- }
2169+ ss := stubserver .StartTestService (t , nil , grpc .InTapHandle (tapHandler ))
21802170 defer ss .Stop ()
21812171
21822172 ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
21832173 defer cancel ()
21842174
2185- _ , err = ss .Client .EmptyCall (ctx , & testpb.Empty {})
2175+ _ , err : = ss .Client .EmptyCall (ctx , & testpb.Empty {})
21862176 if err == nil {
21872177 t .Fatal ("EmptyCall() succeeded; want error" )
21882178 }
21892179
21902180 gotStatus := status .Convert (err )
21912181 if gotStatus .Code () != codes .ResourceExhausted {
2192- t .Fatalf ("EmptyCall() returned code %v; want %v" , gotStatus .Code (), codes .ResourceExhausted )
2182+ t .Errorf ("EmptyCall() returned code %v; want %v" , gotStatus .Code (), codes .ResourceExhausted )
21932183 }
21942184 if gotStatus .Message () != "rate limit exceeded" {
2195- t .Fatalf ("EmptyCall() returned message %q; want %q" , gotStatus .Message (), "rate limit exceeded" )
2185+ t .Errorf ("EmptyCall() returned message %q; want %q" , gotStatus .Message (), "rate limit exceeded" )
21962186 }
21972187
21982188 details := gotStatus .Details ()
0 commit comments