mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 03:01:11 +00:00
* If we don't get a path name from the router, make one up from the url. * Think about route naming a little more and add a comment to show it.
31 lines
937 B
Go
31 lines
937 B
Go
package middleware_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/weaveworks/scope/common/middleware"
|
|
)
|
|
|
|
func TestMakeLabelValue(t *testing.T) {
|
|
for input, want := range map[string]string{
|
|
"/": "root", // special case
|
|
"//": "root", // unintended consequence of special case
|
|
"a": "a",
|
|
"/foo": "foo",
|
|
"foo/": "foo",
|
|
"/foo/": "foo",
|
|
"/foo/bar": "foo_bar",
|
|
"foo/bar/": "foo_bar",
|
|
"/foo/bar/": "foo_bar",
|
|
"/foo/{orgName}/Bar": "foo_orgname_bar",
|
|
"/foo/{org_name}/Bar": "foo_org_name_bar",
|
|
"/foo/{org__name}/Bar": "foo_org_name_bar",
|
|
"/foo/{org___name}/_Bar": "foo_org_name_bar",
|
|
"/foo.bar/baz.qux/": "foo_bar_baz_qux",
|
|
} {
|
|
if have := middleware.MakeLabelValue(input); want != have {
|
|
t.Errorf("%q: want %q, have %q", input, want, have)
|
|
}
|
|
}
|
|
}
|