1//Copyright 2017 Improbable. All Rights Reserved. 2// See LICENSE for licensing terms. 3 4package grpcweb_test 5 6import ( 7 "sort" 8 "testing" 9 10 testproto "github.com/improbable-eng/grpc-web/integration_test/go/_proto/improbable/grpcweb/test" 11 12 "github.com/improbable-eng/grpc-web/go/grpcweb" 13 "github.com/stretchr/testify/assert" 14 "google.golang.org/grpc" 15) 16 17func TestListGRPCResources(t *testing.T) { 18 server := grpc.NewServer() 19 testproto.RegisterTestServiceServer(server, &testServiceImpl{}) 20 expected := []string{ 21 "/improbable.grpcweb.test.TestService/PingEmpty", 22 "/improbable.grpcweb.test.TestService/Ping", 23 "/improbable.grpcweb.test.TestService/PingError", 24 "/improbable.grpcweb.test.TestService/PingList", 25 "/improbable.grpcweb.test.TestService/Echo", 26 "/improbable.grpcweb.test.TestService/PingPongBidi", 27 "/improbable.grpcweb.test.TestService/PingStream", 28 } 29 actual := grpcweb.ListGRPCResources(server) 30 sort.Strings(expected) 31 sort.Strings(actual) 32 assert.EqualValues(t, 33 expected, 34 actual, 35 "list grpc resources must provide an exhaustive list of all registered handlers") 36} 37