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