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: zone_test.go
    path of file: ./repos/cockroach/pkg/config/zonepb
    
    the code of the file until where you have to start completion: // Copyright 2015 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package zonepb

import (
	"context"
	"fmt"
	"math/rand"
	"reflect"
	"testing"

	"github.com/cockroachdb/cockroach/pkg/keys"
	"github.com/cockroachdb/cockroach/pkg/roachpb"
	"github.com/cockroachdb/cockroach/pkg/settings/cluster"
	"github.com/cockroachdb/cockroach/pkg/sql/sem/catconstants"
	"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
	"github.com/cockroachdb/cockroach/pkg/testutils"
	"github.com/cockroachdb/cockroach/pkg/util/leaktest"
	"github.com/cockroachdb/cockroach/pkg/util/timeutil"
	proto "github.com/gogo/protobuf/proto"
	"github.com/stretchr/testify/require"
	yaml "gopkg.in/yaml.v2"
)

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

	testCases := []struct {
		cfg      ZoneConfig
		expected string
	}{
		{
			ZoneConfig{
				NumReplicas: proto.Int32(0),
			},
			"at least one replica is required",
		},
		{
			ZoneConfig{
				NumReplicas: proto.Int32(-1),
			},
			"at least one replica is required",
		},
		{
			ZoneConfig{
				NumReplicas: proto.Int32(2),
			},
			"at least 3 replicas are required for multi-replica configurations",
		},
		{
			ZoneConfig{
				NumReplicas:   proto.Int32(1),
				RangeMaxBytes: proto.Int64(0),
			},
			"RangeMaxBytes 0 less than minimum allowed",
		},
		{
			ZoneConfig{
				NumReplicas:   proto.Int32(1),
				RangeMaxBytes: proto.Int64(60 << 20),
			},
			"RangeMaxBytes 62914560 less than minimum allowed",
		},
		{
			ZoneConfig{
				NumReplicas:   proto.Int32(1),
				RangeMaxBytes: DefaultZoneConfig().RangeMaxBytes,
				GC:            &GCPolicy{TTLSeconds: 0},
			},
			"GC.TTLSeconds 
    
func TestZoneConfigValidateTandemFields(t *testing.T) {
	defer leaktest.AfterTest(t)()

	testCases := []struct {
		name       string
		cfg        ZoneConfig
		expected   string
		shouldFail bool
	}{
		{
			name: "range sizes not set in tandem#1",
			cfg: ZoneConfig{
				RangeMaxBytes: DefaultZoneConfig().RangeMaxBytes,
			},
			expected:   "range_min_bytes and range_max_bytes must be set together",
			shouldFail: true,
		},
		{
			name: "range sizes not set in tandem#2",
			cfg: ZoneConfig{
				RangeMinBytes: DefaultZoneConfig().RangeMinBytes,
			},
			expected:   "range_min_bytes and range_max_bytes must be set together",
			shouldFail: true,
		},
		{
			name: "per-replica constraints without num_replicas",
			cfg: ZoneConfig{
				Constraints: []ConstraintsConjunction{
					{
						Constraints: []Constraint{{Value: "a", Type: Constraint_REQUIRED}},
						NumReplicas: 2,
					},
				},
			},
			expected:   "when per-replica constraints are set, num_replicas must be set as well",
			shouldFail: true,
		},
		{
			name: "per-voter constraints without num_voters",
			cfg: ZoneConfig{
				NumReplicas: proto.Int32(3),
				VoterConstraints: []ConstraintsConjunction{
					{
						Constraints: []Constraint{{Value: "a", Type: Constraint_REQUIRED}},
						NumReplicas: 2,
					},
				},
			},
			expected:   "when voter_constraints are set, num_voters must be set as well",
			shouldFail: true,
		},
		{
			name: "lease preferences without constraints",
			cfg: ZoneConfig{
				InheritedConstraints:      true,
				InheritedLeasePreferences: false,
				LeasePreferences: []LeasePreference{
					{
						Constraints: []Constraint{},
					},
				},
			},
			expected:   "lease preferences can not be set unless the constraints are explicitly set as well",
			shouldFail: true,
		},
		{
			name: "lease preferences without voter_constraints when voters are explicitly configured",
			cfg: ZoneConfig{
				NumVoters:                   proto.Int32(3),
				NumReplicas:                 proto.Int32(3),
				InheritedConstraints:        false,
				NullVoterConstraintsIsEmpty: false,
				InheritedLeasePreferences:   false,
				LeasePreferences: []LeasePreference{
					{
						Constraints: []Constraint{},
					},
				},
			},
			expected:   "lease preferences can not be set unless the voter_constraints are explicitly set as well",
			shouldFail: true,
		},
		{
			name: "lease preferences without voter_constraints when voters not explicitly configured",
			cfg: ZoneConfig{
				InheritedConstraints:        false,
				NullVoterConstraintsIsEmpty: false,
				InheritedLeasePreferences:   false,
				LeasePreferences: []LeasePreference{
					{
						Constraints: []Constraint{},
					},
				},
			},
			shouldFail: false,
		},
	}

	for i, c := range testCases {
		t.Run(c.name, func(t *testing.T) {
			err := c.cfg.ValidateTandemFields()
			if !c.shouldFail {
				require.NoError(t, err)
			} else if !testutils.IsError(err, c.expected) {
				t.Errorf("%d: expected %q, got %v", i, c.expected, err)
			}
		})
	}
}