(t *testing.T, e env)
| 2101 | } |
| 2102 | |
| 2103 | func testTap(t *testing.T, e env) { |
| 2104 | te := newTest(t, e) |
| 2105 | te.userAgent = testAppUA |
| 2106 | ttap := &myTap{} |
| 2107 | te.tapHandle = ttap.handle |
| 2108 | te.startServer(&testServer{security: e.security}) |
| 2109 | defer te.tearDown() |
| 2110 | |
| 2111 | cc := te.clientConn() |
| 2112 | tc := testgrpc.NewTestServiceClient(cc) |
| 2113 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 2114 | defer cancel() |
| 2115 | |
| 2116 | if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); err != nil { |
| 2117 | t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, <nil>", err) |
| 2118 | } |
| 2119 | if ttap.cnt.Load() != 1 { |
| 2120 | t.Fatalf("Get the count in ttap %d, want 1", ttap.cnt.Load()) |
| 2121 | } |
| 2122 | |
| 2123 | if _, err := tc.EmptyCall(metadata.AppendToOutgoingContext(ctx, "return-error", "false"), &testpb.Empty{}); err != nil { |
| 2124 | t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, <nil>", err) |
| 2125 | } |
| 2126 | if ttap.cnt.Load() != 2 { |
| 2127 | t.Fatalf("Get the count in ttap %d, want 2", ttap.cnt.Load()) |
| 2128 | } |
| 2129 | |
| 2130 | if _, err := tc.EmptyCall(metadata.AppendToOutgoingContext(ctx, "return-error", "true"), &testpb.Empty{}); status.Code(err) != codes.Unknown { |
| 2131 | t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, %s", err, codes.Unknown) |
| 2132 | } |
| 2133 | if ttap.cnt.Load() != 3 { |
| 2134 | t.Fatalf("Get the count in ttap %d, want 3", ttap.cnt.Load()) |
| 2135 | } |
| 2136 | |
| 2137 | payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, 31) |
| 2138 | if err != nil { |
| 2139 | t.Fatal(err) |
| 2140 | } |
| 2141 | |
| 2142 | req := &testpb.SimpleRequest{ |
| 2143 | ResponseType: testpb.PayloadType_COMPRESSABLE, |
| 2144 | ResponseSize: 45, |
| 2145 | Payload: payload, |
| 2146 | } |
| 2147 | if _, err := tc.UnaryCall(ctx, req); status.Code(err) != codes.PermissionDenied { |
| 2148 | t.Fatalf("TestService/UnaryCall(_, _) = _, %v, want _, %s", err, codes.PermissionDenied) |
| 2149 | } |
| 2150 | str, err := tc.FullDuplexCall(ctx) |
| 2151 | if err != nil { |
| 2152 | t.Fatalf("Unexpected error creating stream: %v", err) |
| 2153 | } |
| 2154 | if _, err := str.Recv(); status.Code(err) != codes.FailedPrecondition { |
| 2155 | t.Fatalf("FullDuplexCall Recv() = _, %v, want _, %s", err, codes.FailedPrecondition) |
| 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | func (s) TestTapStatusDetails(t *testing.T) { |
| 2160 | tapHandler := func(context.Context, *tap.Info) (context.Context, error) { |
no test coverage detected