Fix GroupsAsSubDomains option for Mesos and Marathon (#868)
* Fix GroupsAsSubDomains option for Mesos and Marathon * Refactor reverseStringSlice function
This commit is contained in:
parent
e34c364d5e
commit
055cd01bb7
5 changed files with 73 additions and 7 deletions
|
@ -1280,3 +1280,33 @@ func TestMarathonGetBackend(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMarathonGetSubDomain(t *testing.T) {
|
||||
providerGroups := &Marathon{GroupsAsSubDomains: true}
|
||||
providerNoGroups := &Marathon{GroupsAsSubDomains: false}
|
||||
|
||||
apps := []struct {
|
||||
path string
|
||||
expected string
|
||||
provider *Marathon
|
||||
}{
|
||||
{"/test", "test", providerNoGroups},
|
||||
{"/test", "test", providerGroups},
|
||||
{"/a/b/c/d", "d.c.b.a", providerGroups},
|
||||
{"/b/a/d/c", "c.d.a.b", providerGroups},
|
||||
{"/d/c/b/a", "a.b.c.d", providerGroups},
|
||||
{"/c/d/a/b", "b.a.d.c", providerGroups},
|
||||
{"/a/b/c/d", "a-b-c-d", providerNoGroups},
|
||||
{"/b/a/d/c", "b-a-d-c", providerNoGroups},
|
||||
{"/d/c/b/a", "d-c-b-a", providerNoGroups},
|
||||
{"/c/d/a/b", "c-d-a-b", providerNoGroups},
|
||||
}
|
||||
|
||||
for _, a := range apps {
|
||||
actual := a.provider.getSubDomain(a.path)
|
||||
|
||||
if actual != a.expected {
|
||||
t.Errorf("expected %q, got %q", a.expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue