(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestLoopbackConn(t *testing.T) { |
| 31 | a := assertions.New(t) |
| 32 | ctx, cancel := context.WithCancel(test.Context()) |
| 33 | defer cancel() |
| 34 | |
| 35 | server := grpc.NewServer() |
| 36 | a.So(server, should.NotBeNil) |
| 37 | rpctest.RegisterFooBarServer(server, &rpctest.FooBarExampleServer{}) |
| 38 | |
| 39 | stats := &statsHandler{} |
| 40 | loopbackConn, err := rpcserver.StartLoopback(ctx, server, grpc.WithStatsHandler(stats)) |
| 41 | a.So(loopbackConn, should.NotBeNil) |
| 42 | a.So(err, should.BeNil) |
| 43 | |
| 44 | cli := rpctest.NewFooBarClient(loopbackConn) |
| 45 | |
| 46 | bar, err := cli.Unary(ctx, &rpctest.Foo{Message: "foo"}) |
| 47 | a.So(err, should.BeNil) |
| 48 | a.So(bar.Message, should.Equal, "foofoo") |
| 49 | |
| 50 | a.So(stats.rpcTag, should.NotBeNil) |
| 51 | a.So(stats.rpcTag.FullMethodName, should.Equal, "/rpctest.FooBar/Unary") |
| 52 | a.So(stats.rpcTag.FailFast, should.Equal, true) |
| 53 | |
| 54 | a.So(stats.connTag, should.NotBeNil) |
| 55 | a.So(stats.connTag.RemoteAddr, should.Resemble, stats.connTag.LocalAddr) |
| 56 | } |
| 57 | |
| 58 | type statsHandler struct { |
| 59 | rpcTag *stats.RPCTagInfo |
nothing calls this directly
no test coverage detected