-
Notifications
You must be signed in to change notification settings - Fork 0
/
gorr_test.go
53 lines (49 loc) · 1.11 KB
/
gorr_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
49
50
51
52
53
package gorr_test
import (
"net/http"
"strings"
"time"
. "github.com/Contra-Culture/gorr"
"github.com/Contra-Culture/report"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func dumbHandler(w http.ResponseWriter, r *http.Request, ps map[string]string) {}
var _ = Describe("gorr", func() {
Describe("router DSL", func() {
var (
d *Dispatcher
r report.Node
)
Context("when configured properly", func() {
It("succeed", func() {
d, r = New(
func(cfg *DispatcherCfgr) {
cfg.Root(
"Test root.",
func(cfg *StaticNodeCfgr) {
})
})
Expect(d).NotTo(BeNil())
Expect(r).NotTo(BeNil())
var sb strings.Builder
fn := func(path []int, k report.Kind, _ time.Time, _ *time.Duration, s string) (err error) {
for range path {
_, err = sb.WriteRune('\t')
if err != nil {
return
}
}
_, err = sb.WriteString(s)
if err != nil {
return
}
_, err = sb.WriteString("\n\n")
return
}
Expect(r.Traverse(fn)).NotTo(HaveOccurred())
Expect(sb.String()).To(Equal("dispatcher\n\n"))
})
})
})
})