MCPcopy
hub / github.com/grpc/grpc-go / testEmptyUnaryWithUserAgent

Function testEmptyUnaryWithUserAgent

test/end2end_test.go:2209–2229  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

2207}
2208
2209func testEmptyUnaryWithUserAgent(t *testing.T, e env) {
2210 te := newTest(t, e)
2211 te.userAgent = testAppUA
2212 te.startServer(&testServer{security: e.security})
2213 defer te.tearDown()
2214
2215 cc := te.clientConn()
2216 tc := testgrpc.NewTestServiceClient(cc)
2217 var header metadata.MD
2218 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
2219 defer cancel()
2220 reply, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.Header(&header))
2221 if err != nil || !proto.Equal(&testpb.Empty{}, reply) {
2222 t.Fatalf("TestService/EmptyCall(_, _) = %v, %v, want %v, <nil>", reply, err, &testpb.Empty{})
2223 }
2224 if v, ok := header["ua"]; !ok || !strings.HasPrefix(v[0], testAppUA) {
2225 t.Fatalf("header[\"ua\"] = %q, %t, want string with prefix %q, true", v, ok, testAppUA)
2226 }
2227
2228 te.srv.Stop()
2229}
2230
2231func (s) TestFailedEmptyUnary(t *testing.T) {
2232 for _, e := range listTestEnv() {

Callers 1

Calls 9

EmptyCallMethod · 0.95
HeaderFunction · 0.92
newTestFunction · 0.70
EqualMethod · 0.65
FatalfMethod · 0.65
StopMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected