package labels

import (
	"testing"

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

	"github.com/tidbcloud/infra-provider/regional-server/api/v1alpha1"
	"github.com/tidbcloud/infra-provider/regional-server/pkg/consts"
)

func TestNewOwnerLabelsForNodePool(t *testing.T) {
	owner := &v1alpha1.NodePool{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "test-nodepool",
			Namespace: "test-ns",
			UID:       types.UID("test-uid"),
		},
	}

	got := NewOwnerLabels(owner)
	require.Equal(t, map[string]string{
		consts.LabelKeyOwnedBy:   "nodepool",
		consts.LabelKeyNamespace: "test-ns",
		consts.LabelKeyName:      "test-nodepool",
		consts.LabelKeyUID:       "test-uid",
	}, got)
}

func TestNewOwnerLabelsForAPPBox(t *testing.T) {
	owner := &v1alpha1.APPBox{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "test-appbox",
			Namespace: "test-ns",
			UID:       types.UID("test-uid"),
		},
	}

	got := NewOwnerLabels(owner)
	require.Equal(t, map[string]string{
		consts.LabelKeyOwnedBy:   "appbox",
		consts.LabelKeyNamespace: "test-ns",
		consts.LabelKeyName:      "test-appbox",
		consts.LabelKeyUID:       "test-uid",
	}, got)
}
