func (s) TestSuccessCaseOneRDSWatch(t *testing.T) {
	rh, fakeClient, ch := setupTests()
	rh.updateRouteNamesToWatch(map[string]bool{route1: true})
	ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
	defer cancel()
	gotRoute, err := fakeClient.WaitForWatchRouteConfig(ctx)
	if err != nil {
		t.Fatalf("xdsClient.WatchRDS failed with error: %v", err)
	}
	if gotRoute != route1 {
		t.Fatalf("xdsClient.WatchRDS called for route: %v, want %v", gotRoute, route1)
	}
	rdsUpdate := xdsclient.RouteConfigUpdate{}
	fakeClient.InvokeWatchRouteConfigCallback(route1, rdsUpdate, nil)
	rhuWant := map[string]xdsclient.RouteConfigUpdate{route1: rdsUpdate}
	select {
	case rhu := <-ch:
		if diff := cmp.Diff(rhu.updates, rhuWant); diff != "" {
			t.Fatalf("got unexpected route update, diff (-got, +want): %v", diff)
		}
	case <-ctx.Done():
		t.Fatal("Timed out waiting for update from update channel.")
	}
	rh.close()
	routeNameDeleted, err := fakeClient.WaitForCancelRouteConfigWatch(ctx)
	if err != nil {
		t.Fatalf("xdsClient.CancelRDS failed with error: %v", err)
	}
	if routeNameDeleted != route1 {
		t.Fatalf("xdsClient.CancelRDS called for route %v, want %v", routeNameDeleted, route1)
	}
}
TestSuccessCaseOneRDSWatch tests the simplest scenario: the rds handler
receives a single route name, starts a watch for that route name, gets a
successful update, and then writes an update to the update channel for
listener to pick up.
package server
import (
	"context"
	"errors"
	"fmt"
	"testing"
	"github.com/google/go-cmp/cmp"
	"google.golang.org/grpc/xds/internal/testutils/fakeclient"
	"google.golang.org/grpc/xds/internal/xdsclient"
)
const (
	route1 = "route1"
	route2 = "route2"
	route3 = "route3"
)
func setupTests() (*rdsHandler, *fakeclient.Client, chan rdsHandlerUpdate) {
	xdsC := fakeclient.NewClient()
	ch := make(chan rdsHandlerUpdate, 1)
	rh := newRDSHandler(xdsC, ch)
	return rh, xdsC, ch
}
func waitForFuncWithNames(ctx context.Context, f func(context.Context) (string, error), names ...string) error {
	wantNames := make(map[string]bool, len(names))
	for _, name := range names {
		wantNames[name] = true
	}
	gotNames := make(map[string]bool, len(names))
	for range wantNames {
		name, err := f(ctx)
		if err != nil {
			return err
		}
		gotNames[name] = true
	}
	if !cmp.Equal(gotNames, wantNames) {
		return fmt.Errorf("got routeNames %v, want %v", gotNames, wantNames)
	}
	return nil
}