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)
| 24 | // when http.NewRequestWithContext fails. This is triggered by providing an invalid |
| 25 | // HTTP method string in the test case. |
| 26 | func 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 | |
| 48 | func TestSimulateHTTP_MultipartRebuildWithPaths_314(t *testing.T) { |
| 49 | ctx := context.Background() |
nothing calls this directly
no test coverage detected