-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_test.go
45 lines (34 loc) · 993 Bytes
/
debug_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
package debug
import (
"testing"
"github.com/atreugo/httptest/assert"
"github.com/savsgio/atreugo/v11"
"github.com/valyala/fasthttp"
)
func assertResponse(t *testing.T, s *atreugo.Atreugo, req *fasthttp.Request) {
t.Helper()
assert.Server(t, req, s, func(resp *fasthttp.Response) {
if statusCode := resp.StatusCode(); statusCode != fasthttp.StatusOK {
t.Errorf("status code %d, want %d", statusCode, fasthttp.StatusOK)
}
if len(resp.Body()) == 0 {
t.Error("body is empty")
}
})
}
func Test_Register_Expvar(t *testing.T) {
s := atreugo.New(atreugo.Config{})
Register(s, Config{})
req := new(fasthttp.Request)
req.SetRequestURI(defaultExpvarURL)
req.Header.SetMethod(defaultExpvarMethod)
assertResponse(t, s, req)
}
func Test_Register_Pprof(t *testing.T) {
s := atreugo.New(atreugo.Config{})
Register(s, Config{})
req := new(fasthttp.Request)
req.SetRequestURI("/debug/pprof/heap")
req.Header.SetMethod(defaultPprofMethod)
assertResponse(t, s, req)
}