Fix GroupsAsSubDomains option for Mesos and Marathon (#868)

* Fix GroupsAsSubDomains option for Mesos and Marathon
* Refactor reverseStringSlice function
This commit is contained in:
Ryan Leary 2016-11-28 08:59:08 -05:00 committed by Emile Vauge
parent e34c364d5e
commit 055cd01bb7
5 changed files with 73 additions and 7 deletions

View file

@ -1,11 +1,12 @@
package provider
import (
"reflect"
"testing"
"github.com/containous/traefik/log"
"github.com/containous/traefik/types"
"github.com/mesosphere/mesos-dns/records/state"
"reflect"
"testing"
)
func TestMesosTaskFilter(t *testing.T) {
@ -244,6 +245,36 @@ func TestMesosLoadConfig(t *testing.T) {
}
}
func TestMesosGetSubDomain(t *testing.T) {
providerGroups := &Mesos{GroupsAsSubDomains: true}
providerNoGroups := &Mesos{GroupsAsSubDomains: false}
apps := []struct {
path string
expected string
provider *Mesos
}{
{"/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)
}
}
}
// test helpers
type (