-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrouting_test.go
62 lines (50 loc) · 1.17 KB
/
routing_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
54
55
56
57
58
59
60
61
62
package min_test
import (
"net/http"
"testing"
"github.com/stretchr/testify/suite"
"github.com/arturovm/min"
"github.com/arturovm/min/mocks"
)
type RoutingTestSuite struct {
suite.Suite
g *min.Group
h *mocks.Handler
registeredPath string
}
func (s *RoutingTestSuite) SetupTest() {
s.h = new(mocks.Handler)
s.g = min.New(s.h).NewGroup("/sub")
s.registeredPath = "/sub/path"
}
func (s *RoutingTestSuite) on(method string) {
s.h.On("Handle", method, s.registeredPath, nil)
}
func (s *RoutingTestSuite) TestGet() {
s.on(http.MethodGet)
s.g.Get("/path", nil)
s.h.AssertExpectations(s.T())
}
func (s *RoutingTestSuite) TestPost() {
s.on(http.MethodPost)
s.g.Post("/path", nil)
s.h.AssertExpectations(s.T())
}
func (s *RoutingTestSuite) TestPut() {
s.on(http.MethodPut)
s.g.Put("/path", nil)
s.h.AssertExpectations(s.T())
}
func (s *RoutingTestSuite) TestPatch() {
s.on(http.MethodPatch)
s.g.Patch("/path", nil)
s.h.AssertExpectations(s.T())
}
func (s *RoutingTestSuite) TestDelete() {
s.on(http.MethodDelete)
s.g.Delete("/path", nil)
s.h.AssertExpectations(s.T())
}
func TestRouting(t *testing.T) {
suite.Run(t, new(RoutingTestSuite))
}