11package openapi_test
22
33import (
4- "github.com/sirupsen/logrus/hooks/test"
5- "github.com/stretchr/testify/require"
64 "mokapi/engine/enginetest"
75 "mokapi/media"
86 "mokapi/providers/openapi"
@@ -11,13 +9,16 @@ import (
119 "net/http"
1210 "net/http/httptest"
1311 "testing"
12+
13+ "github.com/sirupsen/logrus/hooks/test"
14+ "github.com/stretchr/testify/require"
1415)
1516
1617func TestEvent (t * testing.T ) {
1718 testcases := []struct {
1819 name string
1920 config * openapi.Config
20- test func (t * testing.T , h http .Handler )
21+ test func (t * testing.T , h openapi .Handler )
2122 }{
2223 {
2324 name : "use response example (deprecated)" ,
@@ -35,12 +36,13 @@ func TestEvent(t *testing.T) {
3536 )),
3637 )),
3738 ),
38- test : func (t * testing.T , h http .Handler ) {
39+ test : func (t * testing.T , h openapi .Handler ) {
3940 r := httptest .NewRequest ("get" , "http://localhost/foo" , nil )
4041 r .Header .Set ("Content-Type" , "application/json" )
4142 rr := httptest .NewRecorder ()
4243
43- h .ServeHTTP (rr , r )
44+ err := h .ServeHTTP (rr , r )
45+ require .Nil (t , err )
4446 require .Equal (t , http .StatusOK , rr .Code )
4547 require .Equal (t , `"foo"` , rr .Body .String ())
4648 },
@@ -71,12 +73,13 @@ func TestEvent(t *testing.T) {
7173 )),
7274 )),
7375 ),
74- test : func (t * testing.T , h http .Handler ) {
76+ test : func (t * testing.T , h openapi .Handler ) {
7577 r := httptest .NewRequest ("get" , "http://localhost/foo" , nil )
7678 r .Header .Set ("Content-Type" , "application/json" )
7779 rr := httptest .NewRecorder ()
7880
79- h .ServeHTTP (rr , r )
81+ err := h .ServeHTTP (rr , r )
82+ require .Nil (t , err )
8083 require .Equal (t , http .StatusOK , rr .Code )
8184 require .Equal (t , `"foo"` , rr .Body .String ())
8285 },
0 commit comments