mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Added test to check pathPrefix
This commit is contained in:
parent
cd2820e165
commit
b44ce11d1b
|
@ -274,6 +274,41 @@ func TestRoutePrefix(t *testing.T) {
|
|||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||
}
|
||||
|
||||
func TestPathPrefix(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
routePrefix string
|
||||
pathPrefix string
|
||||
}{
|
||||
{
|
||||
routePrefix: "/",
|
||||
// If we have pathPrefix as "/", URL in UI gets "//"" as prefix,
|
||||
// hence doesn't remain relative path anymore.
|
||||
pathPrefix: "",
|
||||
},
|
||||
{
|
||||
routePrefix: "/prometheus",
|
||||
pathPrefix: "/prometheus",
|
||||
},
|
||||
{
|
||||
routePrefix: "/p1/p2/p3/p4",
|
||||
pathPrefix: "/p1/p2/p3/p4",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
opts := &Options{
|
||||
RoutePrefix: test.routePrefix,
|
||||
}
|
||||
|
||||
pathPrefix := tmplFuncs("", opts)["pathPrefix"].(func() string)
|
||||
pp := pathPrefix()
|
||||
|
||||
testutil.Equals(t, test.pathPrefix, pp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDebugHandler(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
prefix, url string
|
||||
|
|
Loading…
Reference in a new issue