Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
997 B

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package catalogv2beta1
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestServiceEndpoints_GetIdentities(t *testing.T) {
cases := map[string]struct {
endpoints []*Endpoint
expIdentities []string
}{
"no endpoints": {
endpoints: nil,
expIdentities: nil,
},
"no identities": {
endpoints: []*Endpoint{
{},
{},
},
expIdentities: nil,
},
"single identity": {
endpoints: []*Endpoint{
{Identity: "foo"},
{Identity: "foo"},
{Identity: "foo"},
},
expIdentities: []string{"foo"},
},
"multiple identities": {
endpoints: []*Endpoint{
{Identity: "foo"},
{Identity: "foo"},
{Identity: "bar"},
},
expIdentities: []string{"bar", "foo"},
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
se := &ServiceEndpoints{Endpoints: c.endpoints}
require.Equal(t, c.expIdentities, se.GetIdentities())
})
}
}