1
0
Fork 0

Added router priority to webui's list and detail page

This commit is contained in:
bendre90 2023-01-09 17:24:05 +01:00 committed by GitHub
parent cd90b9761a
commit 8cd4923e72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 2913 additions and 131 deletions

View file

@ -376,6 +376,10 @@ func Test_addRoutePriority(t *testing.T) {
w.Header().Set("X-From", route.xFrom)
})
if route.priority == 0 {
route.priority = GetRulePriority(route.rule)
}
err := muxer.AddRoute(route.rule, route.priority, handler)
require.NoError(t, err, route.rule)
}
@ -517,3 +521,26 @@ func TestEmptyHost(t *testing.T) {
})
}
}
func TestGetRulePriority(t *testing.T) {
testCases := []struct {
desc string
rule string
expected int
}{
{
desc: "simple rule",
rule: "Host(`example.org`)",
expected: 19,
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
assert.Equal(t, test.expected, GetRulePriority(test.rule))
})
}
}