2021-01-27 23:25:37 +00:00
|
|
|
package util
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2021-10-23 20:47:12 +00:00
|
|
|
func TestConvertGroupAndEndpointNameToKey(t *testing.T) {
|
2021-01-27 23:25:37 +00:00
|
|
|
type Scenario struct {
|
|
|
|
GroupName string
|
2021-10-23 20:47:12 +00:00
|
|
|
EndpointName string
|
2021-01-27 23:25:37 +00:00
|
|
|
ExpectedOutput string
|
|
|
|
}
|
|
|
|
scenarios := []Scenario{
|
|
|
|
{
|
|
|
|
GroupName: "Core",
|
2021-10-23 20:47:12 +00:00
|
|
|
EndpointName: "Front End",
|
2021-01-27 23:25:37 +00:00
|
|
|
ExpectedOutput: "core_front-end",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
GroupName: "Load balancers",
|
2021-10-23 20:47:12 +00:00
|
|
|
EndpointName: "us-west-2",
|
2021-01-27 23:25:37 +00:00
|
|
|
ExpectedOutput: "load-balancers_us-west-2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
GroupName: "a/b test",
|
2021-10-23 20:47:12 +00:00
|
|
|
EndpointName: "a",
|
2021-01-27 23:25:37 +00:00
|
|
|
ExpectedOutput: "a-b-test_a",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, scenario := range scenarios {
|
|
|
|
t.Run(scenario.ExpectedOutput, func(t *testing.T) {
|
2021-10-23 20:47:12 +00:00
|
|
|
output := ConvertGroupAndEndpointNameToKey(scenario.GroupName, scenario.EndpointName)
|
2021-01-27 23:25:37 +00:00
|
|
|
if output != scenario.ExpectedOutput {
|
2021-10-23 20:47:12 +00:00
|
|
|
t.Errorf("expected '%s', got '%s'", scenario.ExpectedOutput, output)
|
2021-01-27 23:25:37 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|