package cluster import ( "testing" "edge-infra.dev/pkg/edge/api/graph/model" "github.com/stretchr/testify/assert" ) type clusterTypeFromLabelsTestCase struct { keys map[string]string output string } func TestGetClusterTypeFromLabels(t *testing.T) { tc := []clusterTypeFromLabelsTestCase{ { keys: map[string]string{"gke": "edge", "radnom": "edge"}, output: "gke", }, { keys: map[string]string{"dsds": "edge", "radnom": "edge"}, output: "dsds", }, { keys: map[string]string{"random": "non", "dsds": "non"}, output: "", }, { keys: map[string]string{"random": "non", "radnom2": "non"}, output: "", }, } for _, c := range tc { var ls []*model.Label for k, v := range c.keys { ls = append(ls, &model.Label{Key: k, Type: v}) } assert.Equal(t, c.output, string(GetClusterTypeFromLabels(ls))) } }