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