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

Function runUnixTest

test/authority_test.go:64–92  ·  view source on GitHub ↗
(t *testing.T, address, target, expectedAuthority string, dialer func(context.Context, string) (net.Conn, error))

Source from the content-addressed store, hash-verified

62}
63
64func runUnixTest(t *testing.T, address, target, expectedAuthority string, dialer func(context.Context, string) (net.Conn, error)) {
65 if !strings.HasPrefix(target, "unix-abstract:") {
66 if err := os.RemoveAll(address); err != nil {
67 t.Fatalf("Error removing socket file %v: %v\n", address, err)
68 }
69 }
70 ss := &stubserver.StubServer{
71 EmptyCallF: func(ctx context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
72 return authorityChecker(ctx, expectedAuthority)
73 },
74 Network: "unix",
75 Address: address,
76 Target: target,
77 }
78 opts := []grpc.DialOption{}
79 if dialer != nil {
80 opts = append(opts, grpc.WithContextDialer(dialer))
81 }
82 if err := ss.Start(nil, opts...); err != nil {
83 t.Fatalf("Error starting endpoint server: %v", err)
84 }
85 defer ss.Stop()
86 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
87 defer cancel()
88 _, err := ss.Client.EmptyCall(ctx, &testpb.Empty{})
89 if err != nil {
90 t.Errorf("us.client.EmptyCall(_, _) = _, %v; want _, nil", err)
91 }
92}
93
94type authorityTest struct {
95 name string

Callers 2

TestUnixMethod · 0.85
TestUnixCustomDialerMethod · 0.85

Calls 7

StartMethod · 0.95
StopMethod · 0.95
WithContextDialerFunction · 0.92
authorityCheckerFunction · 0.70
FatalfMethod · 0.65
EmptyCallMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected