Skip to content

Commit 4f27e35

Browse files
committed
fix test cases with long json payloads to have valid json payloads
1 parent ea270ae commit 4f27e35

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/is_json_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestIsJson(t *testing.T) {
110110
{
111111
name: "No content-type headers with request payload longer than max length",
112112
reqContentType: "",
113-
reqBody: strings.Repeat("a", 1025),
113+
reqBody: `{"key": "` + strings.Repeat("a", 1025) + `"}`,
114114
respContentType: "",
115115
respBody: ``,
116116
maxContentLength: 1024,
@@ -121,7 +121,7 @@ func TestIsJson(t *testing.T) {
121121
reqContentType: "",
122122
reqBody: ``,
123123
respContentType: "",
124-
respBody: strings.Repeat("a", 1025),
124+
respBody: `{"key": "` + strings.Repeat("a", 1025) + `"}`,
125125
maxContentLength: 1024,
126126
expectedResult: false,
127127
},
@@ -156,8 +156,9 @@ func TestIsJson(t *testing.T) {
156156
}
157157

158158
resp := &http.Response{
159-
Header: make(http.Header),
160-
Body: io.NopCloser(strings.NewReader(tt.respBody)),
159+
Header: make(http.Header),
160+
Body: io.NopCloser(strings.NewReader(tt.respBody)),
161+
ContentLength: int64(len(tt.respBody)),
161162
}
162163
if tt.respContentType != "" {
163164
resp.Header.Set("Content-Type", tt.respContentType)

0 commit comments

Comments
 (0)