MCPcopy Create free account
hub / github.com/GoogleChrome/webstatus.dev / assertResponseBody

Function assertResponseBody

backend/pkg/httpserver/server_test.go:1210–1246  ·  view source on GitHub ↗
(t *testing.T, actual, expected io.Reader)

Source from the content-addressed store, hash-verified

1208
1209func (m *MockEventPublisher) PublishCodeScanTask(
1210 _ context.Context,
1211 _ codescantaskv1.CodeScanTaskEvent,
1212) error {
1213 return nil
1214}
1215
1216func TestGetPageSizeOrDefault(t *testing.T) {
1217 testCases := []struct {
1218 name string
1219 inputPageSize *int
1220 expected int
1221 }{
1222 {"Nil input", nil, 100},
1223 {"Input below min", new(0), 100},
1224 {"Valid input (below max)", new(25), 25},
1225 {"Input above max", new(100), 100},
1226 }
1227
1228 for _, tc := range testCases {
1229 t.Run(tc.name, func(t *testing.T) {
1230 result := getPageSizeOrDefault(tc.inputPageSize)
1231 if result != tc.expected {
1232 t.Errorf("Expected %d, got %d", tc.expected, result)
1233 }
1234 })
1235 }
1236}
1237
1238func createEmptyBodyResponse(status int) *http.Response {
1239 // nolint:exhaustruct // WONTFIX - only for test purposes
1240 return &http.Response{
1241 StatusCode: status,
1242 // For no content, the openapi library currently just returns an
1243 // empty string and empty headers
1244 Body: io.NopCloser(strings.NewReader("")),
1245 Header: make(http.Header),
1246 }
1247}
1248
1249// nolint: gochecknoglobals

Callers 1

assertTestServerRequestFunction · 0.70

Calls 1

compareJSONBodiesFunction · 0.70

Tested by

no test coverage detected