github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/helper/envoy/envoy_test.go (about)

     1  package envoy
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/nomad/ci"
     8  	"github.com/hashicorp/nomad/nomad/structs"
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func TestEnvoy_PortLabel(t *testing.T) {
    13  	ci.Parallel(t)
    14  
    15  	for _, tc := range []struct {
    16  		prefix  string
    17  		service string
    18  		suffix  string
    19  		exp     string
    20  	}{
    21  		{prefix: structs.ConnectProxyPrefix, service: "foo", suffix: "", exp: "connect-proxy-foo"},
    22  		{prefix: structs.ConnectMeshPrefix, service: "bar", exp: "connect-mesh-bar"},
    23  	} {
    24  		test := fmt.Sprintf("%s_%s_%s", tc.prefix, tc.service, tc.suffix)
    25  		t.Run(test, func(t *testing.T) {
    26  			result := PortLabel(tc.prefix, tc.service, tc.suffix)
    27  			require.Equal(t, tc.exp, result)
    28  		})
    29  	}
    30  }