package gkemindomains

import (
	"testing"

	"github.com/stretchr/testify/require"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

	cloudv1 "github.com/tidbcloud/infra-api/api/v1"
	"github.com/tidbcloud/infra-provider/pkg/consts"
)

func TestApplicable(t *testing.T) {
	require.False(t, Applicable(nil))
	cluster := &cloudv1.Cluster{ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{cloudv1.ProviderTypeLabel: cloudv1.ProviderTypeGKE},
	}}

	require.False(t, Applicable(cluster))
	cluster.EnableFeature(consts.ClusterFeatureGCP3LayerNodePool)
	require.False(t, Applicable(cluster))
	cluster.Spec.Kubernetes.Cloud.GCP = &cloudv1.CloudGCP{NodeZones: []string{"a", "b", "c"}}
	require.True(t, Applicable(cluster))
	cluster.EnableFeature(consts.ClusterFeatureUseTiDBOperatorV2)
	require.False(t, Applicable(cluster))
}
