...

Source file src/edge-infra.dev/pkg/edge/constants/api/cluster/cluster_test.go

Documentation: edge-infra.dev/pkg/edge/constants/api/cluster

     1  package cluster
     2  
     3  import (
     4  	"testing"
     5  
     6  	"edge-infra.dev/pkg/edge/api/graph/model"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  type clusterTypeFromLabelsTestCase struct {
    12  	keys   map[string]string
    13  	output string
    14  }
    15  
    16  func TestGetClusterTypeFromLabels(t *testing.T) {
    17  	tc := []clusterTypeFromLabelsTestCase{
    18  		{
    19  			keys:   map[string]string{"gke": "edge", "radnom": "edge"},
    20  			output: "gke",
    21  		},
    22  		{
    23  			keys:   map[string]string{"dsds": "edge", "radnom": "edge"},
    24  			output: "dsds",
    25  		},
    26  		{
    27  			keys:   map[string]string{"random": "non", "dsds": "non"},
    28  			output: "",
    29  		},
    30  		{
    31  			keys:   map[string]string{"random": "non", "radnom2": "non"},
    32  			output: "",
    33  		},
    34  	}
    35  	for _, c := range tc {
    36  		var ls []*model.Label
    37  		for k, v := range c.keys {
    38  			ls = append(ls, &model.Label{Key: k, Type: v})
    39  		}
    40  		assert.Equal(t, c.output, string(GetClusterTypeFromLabels(ls)))
    41  	}
    42  }
    43  

View as plain text