chore!: remove deprecated server function and overhaul c examples - #502
Conversation
aa6e96a to
c50ddc1
Compare
This removes the two deprecated functions, and adapts the tests to make
use of the remaining non-deprecated function
`pactffi_create_mock_server_for_transport`; all in preparation to
upgrade the mock server dependency to version 2.
BREAKING CHANGE: The functions `pactffi_create_mock_server` and
`pactffi_create_mock_server_for_pact` have been removed following
their deprecation. Please use the newer
`pactffi_create_mock_server_for_transport` function.
Signed-off-by: JP-Ellis <josh@jpellis.me>
f2d082c to
7171f12
Compare
7fe4407 to
40e343d
Compare
40e343d to
db85c79
Compare
0953fb6 to
9493804
Compare
YOU54F
left a comment
There was a problem hiding this comment.
Looks great dude
Should we have error handling for any ffi function calls which may return an error?
For future, it would be great to add different protocol types on the consumer side, multiple transports on the provider side, both main types of provider verification (via url for webhooks from a consumer pact that has been published but requires verification, or via broker consumer version selectors for regular provider ci builds).
how to setup passing in env vars for broker selectors, and filter descriptions so users can consistently setup each library ( I think that should be in the core - relates to #250 ) - It might be a bit of a mixed bag, the verifier cli supports some env vars https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli
I have support for some in pact ruby v2, pact ruby v1 used some.
All that is an aside from this PR though, great work. ship it!
Will have to just check we do a 0.5.0 release of the FFI and make a decent release note re: breaking changes just to let people know how to switch from the deprecated function to the new one.
9493804 to
585b1c1
Compare
It's one of these things where a proper implementation should absolutely do this, but having error handling every where is also cumbersome and might detract from the main point of these. I'll make a mention of that though in the code/docs.
Absolutely, but this PR already started as a detour 😅 This can be future work.
Yes, absolutely! I did put a not about that in the commit: This can be fleshed out to explain how it should be used. |
| * Example usage: | ||
| * struct ResponseBuffer resp; | ||
| * response_buffer_init(&resp); | ||
| * // ... perform cURL operations that fill resp ... |
There was a problem hiding this comment.
Is it 'fill resp' ? I think it's something like 'frees resp'
There was a problem hiding this comment.
I'm not sure I understand what you mean.
The example is showing that if you create a buffer with response_buffer_init, you then need to free it later with response_buffer_free. The commented out portion is just a placeholder where the user would (typically) fill the response.
There was a problem hiding this comment.
Sorry, I misunderstood. I thought this comment is for the line below response_buffer_free(&resp);, but it isn't.
I have overhauled the consumer example to: - Use `CMake` and the Corrosion package to automatically find and build the FFI (including the header) and link to the necessary dependencies. - Separate out the tests into individual files to help with the end-users' understanding of the tests. The initial motivation was to remove the reliance on deprecated FFI functions. Signed-off-by: JP-Ellis <josh@jpellis.me>
585b1c1 to
a06b954
Compare
|
Thanks Tien for the PR review! Hopefully it all made sense (though I know you're quite familiar with the FFI already 😅) |
a06b954 to
3da99cc
Compare
This is a complete redesign of the provider example, intended to build on top of the consumer example. It (hopefully) provides a reference as to how the FFI is to be used, on both consumer and provider sides. Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
3da99cc to
c6469a7
Compare
This PR started with the intention of upgrading the version of the server in the FFI. I took the opportunity to remove deprecated functions at the same time, which then required an update of the C examples... and here we are now, with the server not upgraded (yet), but with completely overhauled C examples.
So in the end, this PR: