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: tenant_migration_test.go
    path of file: ./repos/cockroach/pkg/ccl/serverccl
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
//     https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package serverccl

import (
	"context"
	"fmt"
	"testing"

	"github.com/cockroachdb/cockroach/pkg/base"
	"github.com/cockroachdb/cockroach/pkg/clusterversion"
	"github.com/cockroachdb/cockroach/pkg/roachpb"
	"github.com/cockroachdb/cockroach/pkg/server"
	"github.com/cockroachdb/cockroach/pkg/server/serverpb"
	"github.com/cockroachdb/cockroach/pkg/settings/cluster"
	"github.com/cockroachdb/cockroach/pkg/testutils"
	"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
	"github.com/cockroachdb/cockroach/pkg/util/leaktest"
	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/stretchr/testify/require"
)

func TestValidateTargetTenantClusterVersion(t *testing.T) {
	defer leaktest.AfterTest(t)()

	prev := clusterversion.ClusterVersion{Version: clusterversion.MinSupported.Version()}
	cur := clusterversion.ClusterVersion{Version: clusterversion.Latest.Version()}
	// In cases where we use prev as the binary version for the test, set the
	// minimum supported version to prev's binary version - 1 Major version.
	prevMsv := clusterversion.ClusterVersion{
		Version: roachpb.Version{
			Major: prev.Version.Major - 1,
			Minor: prev.Version.Minor,
		},
	}

	var tests =
    
func TestValidateTargetTenantClusterVersion(t *testing.T) {
	defer leaktest.AfterTest(t)()

	prev := clusterversion.ClusterVersion{Version: clusterversion.MinSupported.Version()}
	cur := clusterversion.ClusterVersion{Version: clusterversion.Latest.Version()}
	// In cases where we use prev as the binary version for the test, set the
	// minimum supported version to prev's binary version - 1 Major version.
	prevMsv := clusterversion.ClusterVersion{
		Version: roachpb.Version{
			Major: prev.Version.Major - 1,
			Minor: prev.Version.Minor,
		},
	}

	var tests = []struct {
		binaryVersion             roachpb.Version
		binaryMinSupportedVersion roachpb.Version
		targetClusterVersion      clusterversion.ClusterVersion
		expErrMatch               string // empty if expecting a nil error
	}{
		{
			binaryVersion:             cur.Version,
			binaryMinSupportedVersion: prev.Version,
			targetClusterVersion:      prev,
			expErrMatch:               "",
		},
		{
			binaryVersion:             cur.Version,
			binaryMinSupportedVersion: prev.Version,
			targetClusterVersion:      cur,
			expErrMatch:               "",
		},
		{
			binaryVersion:             prev.Version,
			binaryMinSupportedVersion: prevMsv.Version,
			targetClusterVersion:      cur,
			expErrMatch:               fmt.Sprintf("sql server 1 is running a binary version %s which is less than the attempted upgrade version %s", prev.String(), cur.String()),
		},
		{
			binaryVersion:             cur.Version,
			binaryMinSupportedVersion: prev.Version,
			targetClusterVersion:      prevMsv,
			expErrMatch:               fmt.Sprintf("requested tenant cluster upgrade version %s is less than the binary's minimum supported version %s for SQL server instance 1", prevMsv.String(), prev.String()),
		},
	}

	// tenant's minimum supported version <= target version <= node's binary version
	for i, test := range tests {
		t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) {
			defer log.Scope(t).Close(t)

			makeSettings := func() *cluster.Settings {
				st := cluster.MakeTestingClusterSettingsWithVersions(
					test.binaryVersion,
					test.binaryMinSupportedVersion,
					false, /* initializeVersion */
				)
				return st
			}

			s := serverutils.StartServerOnly(t, base.TestServerArgs{
				DefaultTestTenant: base.TestControlsTenantsExplicitly,
				Settings:          makeSettings(),
				Knobs: base.TestingKnobs{
					Server: &server.TestingKnobs{
						BinaryVersionOverride: test.binaryVersion,
						// We're bumping cluster versions manually ourselves. We
						// want to avoid racing with the auto-upgrade process.
						DisableAutomaticVersionUpgrade: make(chan struct{}),
					},
				},
			})
			defer s.Stopper().Stop(context.Background())

			ctx := context.Background()
			upgradePod, err := s.TenantController().StartTenant(ctx,
				base.TestTenantArgs{
					Settings: makeSettings(),
					TenantID: serverutils.TestTenantID(),
					TestingKnobs: base.TestingKnobs{
						Server: &server.TestingKnobs{
							BinaryVersionOverride: test.binaryVersion,
						},
					},
				})
			if err != nil {
				t.Fatal(err)
			}
			defer upgradePod.AppStopper().Stop(context.Background())

			tmServer := upgradePod.MigrationServer().(*server.TenantMigrationServer)
			req := &serverpb.ValidateTargetClusterVersionRequest{
				ClusterVersion: &test.targetClusterVersion,
			}

			_, err = tmServer.ValidateTargetClusterVersion(context.Background(), req)
			if !testutils.IsError(err, test.expErrMatch) {
				t.Fatalf("test %d: got error %s, wanted error matching '%s'", i, err, test.expErrMatch)
			}
		})
	}
}