func (s) TestRDSHandleResponse(t *testing.T) {
	tests := []struct {
		name          string
		rdsResponse   *xdspb.DiscoveryResponse
		wantErr       bool
		wantUpdate    *rdsUpdate
		wantUpdateErr bool
	}{
		// Badly marshaled RDS response.
		{
			name:          "badly-marshaled-response",
			rdsResponse:   badlyMarshaledRDSResponse,
			wantErr:       true,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		// Response does not contain RouteConfiguration proto.
		{
			name:          "no-route-config-in-response",
			rdsResponse:   badResourceTypeInRDSResponse,
			wantErr:       true,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		// No VirtualHosts in the response. Just one test case here for a bad
		// RouteConfiguration, since the others are covered in
		// TestGetClusterFromRouteConfiguration.
		{
			name:          "no-virtual-hosts-in-response",
			rdsResponse:   noVirtualHostsInRDSResponse,
			wantErr:       true,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		// Response contains one good RouteConfiguration, uninteresting though.
		{
			name:          "one-uninteresting-route-config",
			rdsResponse:   goodRDSResponse2,
			wantErr:       false,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		// Response contains one good interesting RouteConfiguration.
		{
			name:          "one-good-route-config",
			rdsResponse:   goodRDSResponse1,
			wantErr:       false,
			wantUpdate:    &rdsUpdate{weightedCluster: map[string]uint32{goodClusterName1: 1}},
			wantUpdateErr: false,
		},
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			testWatchHandle(t, &watchHandleTestcase{
				typeURL:          rdsURL,
				resourceName:     goodRouteName1,
				responseToHandle: test.rdsResponse,
				wantHandleErr:    test.wantErr,
				wantUpdate:       test.wantUpdate,
				wantUpdateErr:    test.wantUpdateErr,
			})
		})
	}
}
// TestRDSHandleResponse starts a fake xDS server, makes a ClientConn to it,
// and creates a v2Client using it. Then, it registers an LDS and RDS watcher
// and tests different RDS responses.
TestRDSHandleResponse starts a fake xDS server, makes a ClientConn to it,
and creates a v2Client using it. Then, it registers an LDS and RDS watcher
and tests different RDS responses.
// TestRDSHandleResponse starts a fake xDS server makes a ClientConn to it // and creates a v2Client using it . Then it registers an LDS and RDS watcher // and tests different RDS responses .
func (s) TestRDSHandleResponse(t *testing.T) {
	tests := []struct {
		name          string
		rdsResponse   *xdspb.DiscoveryResponse
		wantErr       bool
		wantUpdate    *rdsUpdate
		wantUpdateErr bool
	}{
		{
			name:          "badly-marshaled-response",
			rdsResponse:   badlyMarshaledRDSResponse,
			wantErr:       true,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		{
			name:          "no-route-config-in-response",
			rdsResponse:   badResourceTypeInRDSResponse,
			wantErr:       true,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		{
			name:          "no-virtual-hosts-in-response",
			rdsResponse:   noVirtualHostsInRDSResponse,
			wantErr:       true,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		{
			name:          "one-uninteresting-route-config",
			rdsResponse:   goodRDSResponse2,
			wantErr:       false,
			wantUpdate:    nil,
			wantUpdateErr: false,
		},
		{
			name:          "one-good-route-config",
			rdsResponse:   goodRDSResponse1,
			wantErr:       false,
			wantUpdate:    &rdsUpdate{weightedCluster: map[string]uint32{goodClusterName1: 1}},
			wantUpdateErr: false,
		},
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			testWatchHandle(t, &watchHandleTestcase{
				typeURL:          rdsURL,
				resourceName:     goodRouteName1,
				responseToHandle: test.rdsResponse,
				wantHandleErr:    test.wantErr,
				wantUpdate:       test.wantUpdate,
				wantUpdateErr:    test.wantUpdateErr,
			})
		})
	}
}
func ( s ) TestRDSHandleResponse ( t * testing . T ) { tests := [ ] struct { name string rdsResponse * xdspb . DiscoveryResponse wantErr bool wantUpdate * rdsUpdate wantUpdateErr bool } { { name : " " , rdsResponse : badlyMarshaledRDSResponse , wantErr : true , wantUpdate : nil , wantUpdateErr : false , } , { name : " " , rdsResponse : badResourceTypeInRDSResponse , wantErr : true , wantUpdate : nil , wantUpdateErr : false , } , { name : " " , rdsResponse : noVirtualHostsInRDSResponse , wantErr : true , wantUpdate : nil , wantUpdateErr : false , } , { name : " " , rdsResponse : goodRDSResponse2 , wantErr : false , wantUpdate : nil , wantUpdateErr : false , } , { name : " " , rdsResponse : goodRDSResponse1 , wantErr : false , wantUpdate : & rdsUpdate { weightedCluster : map [ string ] uint32 { goodClusterName1 : 1 } } , wantUpdateErr : false , } , } for _ , test := range tests { t . Run ( test . name , func ( t * testing . T ) { testWatchHandle ( t , & watchHandleTestcase { typeURL : rdsURL , resourceName : goodRouteName1 , responseToHandle : test . rdsResponse , wantHandleErr : test . wantErr , wantUpdate : test . wantUpdate , wantUpdateErr : test . wantUpdateErr , } ) } ) } }
TestRDSHandleResponse starts a fake xDS server, makes a ClientConn to it,
and creates a v2Client using it.
TestRDSHandleResponse starts a fake xDS server makes a ClientConn to it and creates a v2Client using it .
// Badly marshaled RDS response. // Response does not contain RouteConfiguration proto. // No VirtualHosts in the response. Just one test case here for a bad // RouteConfiguration, since the others are covered in // TestGetClusterFromRouteConfiguration. // Response contains one good RouteConfiguration, uninteresting though. // Response contains one good interesting RouteConfiguration.