-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrouter_test.go
48 lines (40 loc) · 932 Bytes
/
router_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package corde
import (
"net/http/httptest"
"testing"
"github.com/matryer/is"
)
func TestRoute(t *testing.T) {
assert := is.New(t)
m := NewMux("", Snowflake(0), "")
m.Route("foo", func(m *Mux) {
m.Route("bar", func(m *Mux) {
m.SlashCommand("baz", nil)
})
})
m.Route("/foo", func(m *Mux) {
m.Route("/bar", func(m *Mux) {
m.SlashCommand("/baz", nil)
})
})
m.Route("foo/", func(m *Mux) {
m.Route("bar/", func(m *Mux) {
m.SlashCommand("baz/", nil)
})
})
m.Route("/foo/", func(m *Mux) {
m.Route("/bar/", func(m *Mux) {
m.SlashCommand("/baz/", nil)
})
})
m.SlashCommand("foo/bar/baz", nil)
var commands []string
for cmd := range m.routes.ToMap() {
commands = append(commands, cmd)
}
assert.Equal(commands, []string{"foo/bar/baz"}) // There should only be a single command on the router
}
func TestServeHTTP(t *testing.T) {
m := NewMux("", Snowflake(0), "")
httptest.NewServer(m)
}