Files
weave-scope/common/middleware/instrument_test.go
Tom Wilkie 982189161b If we don't get a path name from the router, make one up from the url. (#1570)
* 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.
2016-06-09 12:48:22 +01:00

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)
}
}
}