MCPcopy
hub / github.com/keploy/keploy / TestSimulateHTTP_NewRequestError_303

Function TestSimulateHTTP_NewRequestError_303

pkg/util_test.go:26–46  ·  view source on GitHub ↗

TestSimulateHTTP_NewRequestError_303 ensures that SimulateHTTP returns an error when http.NewRequestWithContext fails. This is triggered by providing an invalid HTTP method string in the test case.

(t *testing.T)

Source from the content-addressed store, hash-verified

24// when http.NewRequestWithContext fails. This is triggered by providing an invalid
25// HTTP method string in the test case.
26func TestSimulateHTTP_NewRequestError_303(t *testing.T) {
27 // Arrange
28 ctx := context.Background()
29 logger := zap.NewNop()
30 tc := &models.TestCase{
31 Name: "test-case-new-request-error",
32 HTTPReq: models.HTTPReq{
33 Method: "INVALID METHOD", // Invalid method
34 URL: "http://example.com/test",
35 Body: `{"key":"value"}`,
36 },
37 }
38
39 // Act
40 resp, err := SimulateHTTP(ctx, tc, "test-set", logger, SimulationConfig{APITimeout: 10})
41
42 // Assert
43 require.Error(t, err)
44 assert.Contains(t, err.Error(), "invalid method")
45 assert.Nil(t, resp)
46}
47
48func TestSimulateHTTP_MultipartRebuildWithPaths_314(t *testing.T) {
49 ctx := context.Background()

Callers

nothing calls this directly

Calls 2

SimulateHTTPFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected