-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathutil_test.go
32 lines (26 loc) · 1012 Bytes
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package httpserver_test
import (
"testing"
"github.com/ankorstore/yokai/httpserver"
"github.com/stretchr/testify/assert"
)
func TestMatchPrefix(t *testing.T) {
t.Parallel()
prefixes := []string{
"/foo",
"/bar",
}
assert.True(t, httpserver.MatchPrefix(prefixes, "/foo"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/bar"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/fooo"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/barr"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/foo/foo"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/foo/bar"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/bar/bar"))
assert.True(t, httpserver.MatchPrefix(prefixes, "/bar/foo"))
assert.False(t, httpserver.MatchPrefix(prefixes, "/fo"))
assert.False(t, httpserver.MatchPrefix(prefixes, "/ba"))
assert.False(t, httpserver.MatchPrefix(prefixes, "/fo/foo"))
assert.False(t, httpserver.MatchPrefix(prefixes, "/ba/bar"))
assert.False(t, httpserver.MatchPrefix(prefixes, "/baz"))
}