Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pactffi_message_with_metadata_v2 #493

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions native/consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1661,15 +1661,28 @@ Napi::Value PactffiMessageWithContents(const Napi::CallbackInfo& info) {
return env.Undefined();
}


/**
* Adds expected metadata to the Message
*
* * `key` - metadata key
* * `value` - metadata value.
* * `value` - metadata value, supports JSON structures with matchers and generators
*
* To include matching rules for the value, include the
* matching rule JSON format with the value as a single JSON document. I.e.
*
* ```c
* const char* value = "{\"value\": { \"ID\": \"sjhdjkshsdjh\", \"weight\": 100.5 }, \"pact:matcher:type\":\"type\"}";
* pactffi_message_with_metadata_v2(handle, "TagData", value);
* ```
* See [IntegrationJson.md](https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_ffi/IntegrationJson.md)
*
* # Safety
* The key and value parameters must be valid pointers to NULL terminated strings.
*
* C interface:
*
* void pactffi_message_with_metadata(MessageHandle message_handle,
* void pactffi_message_with_metadata_v2(MessageHandle message_handle,
* const char *key,
* const char *value);
*/
Expand All @@ -1696,7 +1709,7 @@ Napi::Value PactffiMessageWithMetadata(const Napi::CallbackInfo& info) {
std::string key = info[1].As<Napi::String>().Utf8Value();
std::string value = info[2].As<Napi::String>().Utf8Value();

pactffi_message_with_metadata(handle, key.c_str(), value.c_str());
pactffi_message_with_metadata_v2(handle, key.c_str(), value.c_str());

return env.Undefined();
}
Expand Down
Loading