Fix HTTP Spec priority header parsing

This commit is contained in:
Philipp Heckel 2022-07-01 09:28:42 -04:00
parent bd6f3ca2e8
commit 95bd876be2
3 changed files with 19 additions and 3 deletions

View file

@ -60,13 +60,23 @@ func TestParsePriority(t *testing.T) {
}
func TestParsePriority_Invalid(t *testing.T) {
priorities := []string{"-1", "6", "aa", "-"}
priorities := []string{"-1", "6", "aa", "-", "o=1"}
for _, priority := range priorities {
_, err := ParsePriority(priority)
require.Equal(t, errInvalidPriority, err)
}
}
func TestParsePriority_HTTPSpecPriority(t *testing.T) {
priorities := []string{"u=1", "u=3", "u=7, i"} // see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-priority
for _, priority := range priorities {
_, err := ParsePriority(priority)
actual, err := ParsePriority(priority)
require.Nil(t, err)
require.Equal(t, 3, actual) // Always expect 3!
}
}
func TestPriorityString(t *testing.T) {
priorities := []int{0, 1, 2, 3, 4, 5}
expected := []string{"default", "min", "low", "default", "high", "max"}