77
88 "github.com/infraboard/mcube/http/router"
99 "github.com/infraboard/mcube/http/router/httprouter"
10- "github.com/stretchr/testify/require "
10+ "github.com/stretchr/testify/assert "
1111)
1212
1313func TestSubRouterTestSuit (t * testing.T ) {
@@ -22,14 +22,14 @@ func TestSubRouterTestSuit(t *testing.T) {
2222
2323func newSubRouterTestSuit (t * testing.T ) * subRouterTestSuit {
2424 return & subRouterTestSuit {
25- should : require .New (t ),
25+ should : assert .New (t ),
2626 }
2727}
2828
2929type subRouterTestSuit struct {
3030 root router.Router
3131 sub router.SubRouter
32- should * require .Assertions
32+ should * assert .Assertions
3333}
3434
3535func (s * subRouterTestSuit ) SetUp () {
@@ -69,13 +69,14 @@ func (a *subRouterTestSuit) testAddPublictOK() func(t *testing.T) {
6969
7070func (a * subRouterTestSuit ) testResourceRouterOK () func (t * testing.T ) {
7171 return func (t * testing.T ) {
72- a .sub .ResourceRouter ("resources" ) .AddPublict ("GET" , "/" , IndexHandler )
72+ a .sub .ResourceRouter ("resourceName" , router . NewLable ( "k1" , "v1" )) .AddPublict ("GET" , "/resources " , IndexHandler )
7373
7474 w := httptest .NewRecorder ()
75- req , _ := http .NewRequest ("GET" , "/v1/resources/ " , nil )
75+ req , _ := http .NewRequest ("GET" , "/v1/resources" , nil )
7676 a .root .ServeHTTP (w , req )
7777
78- t . Log ( a .root .GetEndpoints ())
78+ entry := a .root .GetEndpoints (). GetEntry ( "/v1/resources" , "GET" )
7979 a .should .Equal (w .Code , 200 )
80+ a .should .Equal (entry .Labels ["k1" ], "v1" )
8081 }
8182}
0 commit comments