You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: routers_test.go
    path of file: ./repos/google-cloud-go/bigquery/storage/managedwriter
    
    the code of the file until where you have to start completion: // Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRAN
    
func TestSharedRouter_Multiplex(t *testing.T) {
	ctx, cancel := context.WithCancel(context.Background())

	pool := &connectionPool{
		id:     newUUID(poolIDPrefix),
		ctx:    ctx,
		cancel: cancel,
		open: func(ctx context.Context, opts ...gax.CallOption) (storagepb.BigQueryWrite_AppendRowsClient, error) {
			return &testAppendRowsClient{}, nil
		},
		baseFlowController: newFlowController(2, 10),
	}
	defer pool.Close()

	router := newSharedRouter(true, 3)
	if err := pool.activateRouter(router); err != nil {
		t.Errorf("activateRouter: %v", err)
	}

	wantConnCount := 0
	if got := len(router.multiConns); wantConnCount != got {
		t.Errorf("wanted %d conns, got %d", wantConnCount, got)
	}

	writerA := &ManagedStream{
		id:             newUUID(writerIDPrefix),
		streamSettings: &streamSettings{streamID: "projects/foo/datasets/bar/tables/baz/streams/_default"},
		ctx:            ctx,
		cancel:         cancel,
	}
	if err := pool.router.writerAttach(writerA); err != nil {
		t.Fatalf("writerA attach: %v", err)
	}

	// after a writer attached, we expect one conn.
	wantConnCount = 1
	if got := len(router.multiConns); wantConnCount != got {
		t.Errorf("wanted %d conns, got %d", wantConnCount, got)
	}

	writerB := &ManagedStream{
		id:             newUUID(writerIDPrefix),
		streamSettings: &streamSettings{streamID: "projects/foo/datasets/bar/tables/baz/streams/_default"},
		ctx:            ctx,
		cancel:         cancel,
	}
	if err := pool.router.writerAttach(writerB); err != nil {
		t.Fatalf("writerA attach: %v", err)
	}
	writerC := &ManagedStream{
		id:             newUUID(writerIDPrefix),
		streamSettings: &streamSettings{streamID: "projects/foo/datasets/bar/tables/baz/streams/_default"},
		ctx:            ctx,
		cancel:         cancel,
	}
	if err := pool.router.writerAttach(writerC); err != nil {
		t.Fatalf("writerA attach: %v", err)
	}

	wantConnCount = 1
	if got := len(router.multiConns); wantConnCount != got {
		t.Fatalf("wanted %d conns, got %d", wantConnCount, got)
	}

	pw := newPendingWrite(ctx, writerA, &storagepb.AppendRowsRequest{}, nil, "", "")
	conn, err := router.pickConnection(pw)
	if err != nil {
		t.Fatalf("pickConnection writerA: %v", err)
	}
	// generate fake load on the conn associated with writer A
	conn.fc.acquire(ctx, 1)
	conn.fc.acquire(ctx, 1)

	if !conn.isLoaded() {
		t.Errorf("expected conn to be loaded, was not")
	}
	// wait for a watchdog interval
	time.Sleep(watchDogInterval * 2)

	wantConnCount = 2
	// grab read lock so we can assert internal state of the router
	router.multiMu.RLock()
	defer router.multiMu.RUnlock()
	if got := len(router.multiConns); wantConnCount != got {
		t.Fatalf("wanted %d conns, got %d", wantConnCount, got)
	}
	gotLoad0 := router.multiConns[0].curLoad()
	gotLoad1 := router.multiConns[1].curLoad()
	if gotLoad0 > gotLoad1 {
		t.Errorf("expected connections to be ordered by load, got %f, %f", gotLoad0, gotLoad1)
	}
	// verify that rebalance occurred
	connsWithWriters := 0
	for _, v := range router.invertedMultiMap {
		if len(v) > 0 {
			connsWithWriters++
		}
	}
	if connsWithWriters < wantConnCount {
		t.Errorf("wanted at least %d connections to have writers attached, got %d", wantConnCount, connsWithWriters)
	}

}