You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pact-reference: libpact_mock_server_ffi built from master (cargo build --release)
馃挰 Description
When writing a pact test where the request body includes a matcher, the response from mock server is Server Error, status code: 500.
Update:
Happens with POST and request body without a matcher too, but when I used PUT and passed a a request body without a matcher, I received a 201 response as expected.
No change even when specifically defining the request's expected headers to be Content-Type: application/json.
馃Χ Reproduction Steps
Steps to reproduce the behavior:
Prepare a unit test that generates a Pact object where a matcher is in the request body
Pass Pact object to libpact_mock_server_ffi
Trigger network request to test the interaction
馃 Expected Results
The response from mock server returns the value provided in the matcher and status code as defined in pact test.
馃槻 Actual Results
The response from mock server returns 500 - Server Error.
馃尦 Logs
Pact object sent to libpact_mock_server_ffi.create_mock_server()
Update, perhaps it has to do with existing Pact file in PACT_OUTPUT_DIR?
Or maybe having multiple tests setup with same path, query and body but different method?
The following test written in PactSwift passes just fine:
func testMockService_Succeeds_ForPOSTRequestWithMatchersInRequestBody(){
mockService
.uponReceiving("Request to create a new user").given("user does not exist").withRequest(
method:.POST,
path:"/user/add",
query:nil,
headers:["Content-Type":"application/json"],
body:["name":Matcher.SomethingLike("Joe"),"age":Matcher.IntegerLike(42)]).willRespondWith(
status:201)lettestExpectation=expectation(description: #function)
mockService.run{ completion inletrequestURL=URL(string:"\(self.mockService.baseUrl)/user/add")!
letsession=URLSession.shared
varrequest=URLRequest(url: requestURL)
request.httpMethod ="POST"
request.setValue("application/json", forHTTPHeaderField:"Content-Type")
request.httpBody =#"{"name":"Joseph","age":24}"#.data(using:.utf8)lettask= session.dataTask(with: request){ data, response, error in
if let response = response as?HTTPURLResponse{XCTAssertEqual(response.statusCode,201)}
testExpectation.fulfill()completion()}
task.resume()}waitForExpectations(timeout:1)}
馃寧 Environment
libpact_mock_server_ffi
built frommaster
(cargo build --release)馃挰 Description
When writing a pact test where the request body includes a matcher, the response from mock server is
Server Error, status code: 500
.Update:
Happens with
POST
and request body without a matcher too, but when I usedPUT
and passed a a request body without a matcher, I received a201
response as expected.No change even when specifically defining the request's expected headers to be
Content-Type: application/json
.馃Χ Reproduction Steps
Steps to reproduce the behavior:
馃 Expected Results
The response from mock server returns the value provided in the matcher and status code as defined in pact test.
馃槻 Actual Results
The response from mock server returns
500
- Server Error.馃尦 Logs
Pact object sent to
libpact_mock_server_ffi.create_mock_server()
馃搫 Stack Traces
馃 Relationships
The text was updated successfully, but these errors were encountered: