MCPcopy
hub / github.com/google/ax / startMockGRPCServer

Function startMockGRPCServer

internal/controller/registry_test.go:36–52  ·  view source on GitHub ↗
(t *testing.T, healthy bool)

Source from the content-addressed store, hash-verified

34}
35
36func startMockGRPCServer(t *testing.T, healthy bool) (string, func()) {
37 lis, err := net.Listen("tcp", "localhost:0")
38 if err != nil {
39 t.Fatalf("failed to listen: %v", err)
40 }
41 s := grpc.NewServer()
42 proto.RegisterAgentServiceServer(s, &mockAgentServer{healthy: healthy})
43 go func() {
44 if err := s.Serve(lis); err != nil {
45 // server might be closed
46 }
47 }()
48 return lis.Addr().String(), func() {
49 s.Stop()
50 lis.Close()
51 }
52}
53
54func TestRegistry_GracefulShutdown(t *testing.T) {
55 r := NewRegistry()

Callers 1

Calls 4

ServeMethod · 0.95
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected