Files
gatus/util/key_test.go
T

36 lines
856 B
Go
Raw Normal View History

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