package constant

import (
	"testing"

	. "github.com/onsi/gomega"
)

func Test_MetricType(t *testing.T) {
	g := NewGomegaWithT(t)

	testCases := []struct {
		mt              MetricType
		expected        string
		isStorageMetric bool
		isTrafficMetric bool
	}{
		{
			mt:              MetricTypeTikvStorage,
			expected:        "tikv_storage",
			isStorageMetric: true,
			isTrafficMetric: false,
		}, {
			mt:              MetricTypeTiflashStorage,
			expected:        "tiflash_storage",
			isStorageMetric: true,
			isTrafficMetric: false,
		}, {
			mt:              MetricTypeTidbRU,
			expected:        "tidb_ru",
			isStorageMetric: false,
			isTrafficMetric: false,
		}, {
			mt:              MetricTypeLoadDataRU,
			expected:        "load_data_ru",
			isStorageMetric: false,
			isTrafficMetric: false,
		}, {
			mt:              MetricTypeTiflashRU,
			expected:        "tiflash_ru",
			isStorageMetric: false,
			isTrafficMetric: false,
		}, {
			mt:              MetricTypePublicEgress,
			expected:        "public_egress",
			isStorageMetric: false,
			isTrafficMetric: true,
		}, {
			mt:              MetricType("unknown"),
			expected:        "unknown",
			isStorageMetric: false,
			isTrafficMetric: false,
		},
	}

	for _, tc := range testCases {
		g.Expect(tc.mt.String()).To(Equal(tc.expected))
		g.Expect(tc.mt.IsStorageMetric()).To(Equal(tc.isStorageMetric))
		g.Expect(tc.mt.IsTrafficMetric()).To(Equal(tc.isTrafficMetric))
	}
}

func Test_SkuType(t *testing.T) {
	g := NewGomegaWithT(t)

	testCases := []struct {
		st       SkuType
		expected string
	}{
		{
			st:       SkuTypeRowStorage,
			expected: "row_storage",
		}, {
			st:       SkuTypeColumnStorage,
			expected: "column_storage",
		}, {
			st:       SkuTypeRequestUnit,
			expected: "request_unit",
		}, {
			st:       SkuType("unknown"),
			expected: "unknown",
		},
	}

	for _, tc := range testCases {
		g.Expect(tc.st.String()).To(Equal(tc.expected))
	}
}
