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

Method TestDefaultServiceConfig

clientconn_test.go:840–889  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

838}
839
840func (s) TestDefaultServiceConfig(t *testing.T) {
841 const defaultSC = `
842{
843 "methodConfig": [
844 {
845 "name": [
846 {
847 "service": "foo",
848 "method": "bar"
849 }
850 ],
851 "waitForReady": true
852 }
853 ]
854}`
855 tests := []struct {
856 name string
857 testF func(t *testing.T, r *manual.Resolver, addr, sc string)
858 sc string
859 }{
860 {
861 name: "invalid-service-config",
862 testF: testInvalidDefaultServiceConfig,
863 sc: "",
864 },
865 {
866 name: "resolver-service-config-disabled",
867 testF: testDefaultServiceConfigWhenResolverServiceConfigDisabled,
868 sc: defaultSC,
869 },
870 {
871 name: "resolver-does-not-return-service-config",
872 testF: testDefaultServiceConfigWhenResolverDoesNotReturnServiceConfig,
873 sc: defaultSC,
874 },
875 {
876 name: "resolver-returns-invalid-service-config",
877 testF: testDefaultServiceConfigWhenResolverReturnInvalidServiceConfig,
878 sc: defaultSC,
879 },
880 }
881
882 for _, test := range tests {
883 t.Run(test.name, func(t *testing.T) {
884 r := manual.NewBuilderWithScheme(test.name)
885 addr := r.Scheme() + ":///non.existent"
886 test.testF(t, r, addr, test.sc)
887 })
888 }
889}
890
891func verifyWaitForReadyEqualsTrue(cc *ClientConn) bool {
892 var i int

Callers

nothing calls this directly

Calls 2

NewBuilderWithSchemeFunction · 0.92
SchemeMethod · 0.65

Tested by

no test coverage detected