3 * Copyright 2017 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
27 func TestParseLoadBalancer(t *testing.T) {
28 testcases := []struct {
35 "loadBalancingPolicy": "round_robin",
49 LB: newString("round_robin"),
50 Methods: map[string]MethodConfig{
52 WaitForReady: newBool(true),
60 "loadBalancingPolicy": 1,
78 for _, c := range testcases {
79 sc, err := parseServiceConfig(c.scjs)
80 if c.wantErr != (err != nil) || !reflect.DeepEqual(sc, c.wantSC) {
81 t.Fatalf("parseServiceConfig(%s) = %+v, %v, want %+v, %v", c.scjs, sc, err, c.wantSC, c.wantErr)
86 func TestPraseWaitForReady(t *testing.T) {
87 testcases := []struct {
107 Methods: map[string]MethodConfig{
109 WaitForReady: newBool(true),
125 "waitForReady": false
130 Methods: map[string]MethodConfig{
132 WaitForReady: newBool(false),
166 for _, c := range testcases {
167 sc, err := parseServiceConfig(c.scjs)
168 if c.wantErr != (err != nil) || !reflect.DeepEqual(sc, c.wantSC) {
169 t.Fatalf("parseServiceConfig(%s) = %+v, %v, want %+v, %v", c.scjs, sc, err, c.wantSC, c.wantErr)
174 func TestPraseTimeOut(t *testing.T) {
175 testcases := []struct {
195 Methods: map[string]MethodConfig{
197 Timeout: newDuration(time.Second),
248 for _, c := range testcases {
249 sc, err := parseServiceConfig(c.scjs)
250 if c.wantErr != (err != nil) || !reflect.DeepEqual(sc, c.wantSC) {
251 t.Fatalf("parseServiceConfig(%s) = %+v, %v, want %+v, %v", c.scjs, sc, err, c.wantSC, c.wantErr)
256 func TestPraseMsgSize(t *testing.T) {
257 testcases := []struct {
272 "maxRequestMessageBytes": 1024,
273 "maxResponseMessageBytes": 2048
278 Methods: map[string]MethodConfig{
280 MaxReqSize: newInt(1024),
281 MaxRespSize: newInt(2048),
297 "maxRequestMessageBytes": "1024",
298 "maxResponseMessageBytes": "2048"
307 "maxRequestMessageBytes": 1024,
308 "maxResponseMessageBytes": 2048
317 for _, c := range testcases {
318 sc, err := parseServiceConfig(c.scjs)
319 if c.wantErr != (err != nil) || !reflect.DeepEqual(sc, c.wantSC) {
320 t.Fatalf("parseServiceConfig(%s) = %+v, %v, want %+v, %v", c.scjs, sc, err, c.wantSC, c.wantErr)