Skip to content

Commit 652929b

Browse files
committed
rew! WIP chore(deps): remove testutil
1 parent 649f3f5 commit 652929b

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

internal/test/chi/oapi_validate_test.go

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package chi
22

33
import (
4+
"bytes"
45
"context"
56
_ "embed"
7+
"encoding/json"
68
"errors"
79
"io"
810
"net/http"
@@ -15,7 +17,6 @@ import (
1517
"github.com/getkin/kin-openapi/openapi3"
1618
"github.com/getkin/kin-openapi/openapi3filter"
1719
"github.com/go-chi/chi/v5"
18-
"github.com/oapi-codegen/testutil"
1920
"github.com/stretchr/testify/assert"
2021
"github.com/stretchr/testify/require"
2122
)
@@ -29,8 +30,16 @@ func doGet(t *testing.T, mux http.Handler, rawURL string) *httptest.ResponseReco
2930
t.Fatalf("Invalid url: %s", rawURL)
3031
}
3132

32-
response := testutil.NewRequest().Get(u.RequestURI()).WithHost(u.Host).WithAcceptJson().GoWithHTTPHandler(t, mux)
33-
return response.Recorder
33+
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
34+
require.NoError(t, err)
35+
36+
req.Header.Set("accept", "application/json")
37+
38+
rr := httptest.NewRecorder()
39+
40+
mux.ServeHTTP(rr, req)
41+
42+
return rr
3443
}
3544

3645
func doPost(t *testing.T, mux http.Handler, rawURL string, jsonBody interface{}) *httptest.ResponseRecorder {
@@ -39,8 +48,19 @@ func doPost(t *testing.T, mux http.Handler, rawURL string, jsonBody interface{})
3948
t.Fatalf("Invalid url: %s", rawURL)
4049
}
4150

42-
response := testutil.NewRequest().Post(u.RequestURI()).WithHost(u.Host).WithJsonBody(jsonBody).GoWithHTTPHandler(t, mux)
43-
return response.Recorder
51+
data, err := json.Marshal(jsonBody)
52+
require.NoError(t, err)
53+
54+
req, err := http.NewRequest(http.MethodGet, u.String(), bytes.NewReader(data))
55+
require.NoError(t, err)
56+
57+
req.Header.Set("content-type", "application/json")
58+
59+
rr := httptest.NewRecorder()
60+
61+
mux.ServeHTTP(rr, req)
62+
63+
return rr
4464
}
4565

4666
func TestOapiRequestValidator(t *testing.T) {

0 commit comments

Comments
 (0)