-
Notifications
You must be signed in to change notification settings - Fork 31
/
router_test.go
58 lines (50 loc) · 1.01 KB
/
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
49
50
51
52
53
54
55
56
57
58
package types_test
import (
"testing"
"github.com/stretchr/testify/suite"
sdk "github.com/line/lbm-sdk/v2/types"
)
type routeTestSuite struct {
suite.Suite
}
func TestRouteTestSuite(t *testing.T) {
suite.Run(t, new(routeTestSuite))
}
func (s *routeTestSuite) SetupSuite() {
s.T().Parallel()
}
func (s *routeTestSuite) TestNilRoute() {
tests := []struct {
name string
route sdk.Route
expected bool
}{
{
name: "all empty",
route: sdk.NewRoute("", nil),
expected: true,
},
{
name: "only path",
route: sdk.NewRoute("some", nil),
expected: true,
},
{
name: "only handler",
route: sdk.NewRoute("", func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
return nil, nil
}),
expected: true,
},
{
name: "correct route",
route: sdk.NewRoute("some", func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
return nil, nil
}),
expected: false,
},
}
for _, tt := range tests {
s.Require().Equal(tt.expected, tt.route.Empty())
}
}