pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

When using any other type than `application/json` in `pactffi_with_body` the match does not work #234

Closed leonasa closed 1 year ago

leonasa commented 1 year ago

Calling the function this way: let json_ct = CString::new("application/vnd.schemaregistry.v1+json").unwrap(); let json = "{\"test\":true}"; let body = CString::new(json).unwrap(); let result = pactffi_with_body(i_handle, InteractionPart::Request, json_ct.as_ptr(), body.as_ptr());

we should expect to have the interaction1.request.body.content_type() == "application/vnd.schemaregistry.v1+json" but it sets the default value instead. it is done in the function pactffi_with_body exactly here: let body = if reqres.request.content_type().unwrap_or_default().is_json() { let category = reqres.request.matching_rules.add_category("body"); OptionalBody::Present(Bytes::from(process_json(body.to_string(), category, &mut reqres.request.generators)), Some(JSON.clone()), None) }