Adam Rodger (pact-net)
05/02/2023, 2:29 PM/pact-messages
endpoint as if they're async requests, which then fails because obviously those are in a completely different format to what's expected.
What am I supposed to do in that situation?Tien Vo
05/05/2023, 10:21 AM/pact-messages
endpoint to get messages to verify? it always call to /
in my case. absolute path will be <http://my-provider.com/>
conpare to your <http://your-provider.com/pact-messages>
Priyaranjan Mudliar
05/07/2023, 6:29 AM"No driver init in dynamic library"
I have tried multiple ways to load the pact ffi shared library but getting errors similar to the above one, any help would be appreciated. Thanks in advance!Tien Vo
05/08/2023, 4:35 AMScript phpunit --debug -c example/phpunit.all.xml handling the test event returned with error code -1073741819
Yousaf Nabi (pactflow.io)
cargo.toml
files and some of the repos I know that consume the ffi.
Documented here https://github.com/pact-foundation/devrel/issues/10
There may be more outside our wheelhouse, or some that I've missed
The pact-reference (rust) corePriyaranjan Mudliar
05/15/2023, 4:40 AM## Load pact into Mock Server and start
mock_server_port = lib.pactffi_create_mock_server(ffi.new("char[]", json.dumps(contents).encode('ascii')) , b'127.0.0.1:4432',0)
print(f"Mock server started: {mock_server_port}")
pactffi_create_mock_server
seems deprecated as per the pact_ffi documentation, should i be using this or the function thats mentioned in the documentation - pactffi_create_mock_server_for_transport
?Priyaranjan Mudliar
05/15/2023, 2:27 PMpactffi_new_pact
is defined as this in the pact.h file:
typedef uint16_t PactHandle;
The problem is when i am calling pactffi_create_mock_server_for_transport
with PactHandle as lets say 1 (uint16_t
) , it returns me -1 which means An invalid handle was received. Handles should be created with pactffi_new_pact
Am i missing something here? Thanks in advance
Edit: I am writing wrappers for these functions in C, so that I can then finally use Erlang NIFs to call these wrapper functionsPriyaranjan Mudliar
05/17/2023, 9:52 AM%% pact-erlang (very pre-alpha phase right now)
%% Setup
PactRef = pact:create_new_pact(<<"consumer">>, <<"producer">>).
InteractionRef = pact:create_new_interaction(PactRef, <<"/users api desc">>).
pact:insert_request_path(InteractionRef, <<"GET">>, <<"/users">>).
ResponseJsonString = jsx:encode(#{auth_id => 1}).
pact:insert_response_body(InteractionRef, <<"application/json">>, ResponseJsonString).
pact:insert_response_status(InteractionRef, 200).
pact:create_mock_server(PactRef, <<"localhost">>, 1234, <<"http">>).
%% Sample test code
Users = user:get_users(),
%% Verify
assertEqual({ok, matched}, pact:verify_pact(1234)).
%% Write Pact File
pact:write_pact_file(PactRef, "/Users/priyaranjan.m/pacts", 0)
%% Cleanup test setup
pact:cleanup_pact_setup()
Priyaranjan Mudliar
05/22/2023, 10:22 AMpactffi_new_interaction
https://docs.rs/pact_ffi/latest/pact_ffi/mock_server/handles/fn.pactffi_new_interaction.html and this
pactffi_given
https://docs.rs/pact_ffi/latest/pact_ffi/mock_server/handles/fn.pactffi_given.htmlMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
2023-06-26T11:29:54.651109Z DEBUG tokio-runtime-worker pact_mock_server::hyper_server:
----------------------------------------------------------------------------------------
method: GET
path: /product/10
query: None
headers: Some({"accept": ["application/json", "text/plain", "*/*"], "user-agent": ["axios/0.27.2"], "authorization": ["Bearer 2023-06-26T11:29:54.591Z"], "connection": ["close"], "host": ["127.0.0.1:52291"]})
body: Empty
----------------------------------------------------------------------------------------
Matt (pactflow.io / pact-js / pact-go)
Adam Rodger (pact-net)
06/26/2023, 2:14 PMpact_verifier_set_provider_info
FFI call (here ) includes adding a default transport when setting up the verifier, but this makes integrating with the FFI awkward for libraries.
Since Pact Spec v4, a pact file can now contain both HTTP and message interactions, and this is implemented by adding a transport for both HTTP and messaging via pact_verifier_add_provider_transport
(here). The problem is that when the user is setting up a verifier, they want to specify 3 things:
• The provider name
• The HTTP endpoint
• The messaging endpoint
The FFI forces them to treat those as two things instead of three though, because specifying the provider name forces you to supply a transport. This creates an awkward API because there are three possible combinations for setting up a verifier:
• HTTP only
• Messaging only
• Both HTTP and messaging
Plus in future there may also be plugin-based transports, which creates a combinatorial explosion.
You can kinda deal with this in library code by either storing the name up and only adding it once the user has either specified HTTP or messaging, or you can check if you've already added a transport when you add subsequent ones and call different FFI methods. That's what PactNet does here
That's an awkward thing that every library developer has to implement though, and they may implement them differently. Instead I'd prefer if the FFI allowed you to specify the provider info without having to specify a transport, and then initialising the verifier and adding the transports are separated and easy to integrate with.Priyaranjan Mudliar
07/31/2023, 8:35 AMTien Vo
08/22/2023, 9:24 AMpactffi_with_multipart_file
before? Do you know how to use it properly?Tien Vo
08/22/2023, 9:26 AM2023-08-22T091848.367683Z DEBUG tokio-runtime-worker pact_matching: --> Mismatches: [BodyMismatch { path: "$", expected: Some(b"testing"), actual: Some(b"testing"), mismatch: "MIME part 'personal_note': Unable to match 'testing' using ContentType(\"text/plain\")" }]
Jonatan Jaworski
09/05/2023, 1:06 AMError Message:
System.DllNotFoundException : Unable to load shared library 'pact_ffi' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libpact_ffi: No such file or directory
There are no apk packages for libpact_ffi
as far as I know, do you know what I could be missing here?Hazem Borham
09/28/2023, 6:47 PMdyld[10799]: Library not loaded: libpact_ffi.dylib
Referenced from: <71696BE6-E884-368C-9BB5-72CEEC86D657> /private/var/folders/c6/3v5whjln5kgb0mwyjl8djklh0000gn/T/go-build482239365/b001/contracts.test
Reason: tried: 'libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpact_ffi.dylib' (no such file), 'libpact_ffi.dylib' (no such file), '/Users/redacted/integrations/tests/contracts/libpact_ffi.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/redacted/integrations/tests/contracts/libpact_ffi.dylib' (no such file), '/Users/redacted/integrations/tests/contracts/libpact_ffi.dylib' (no such file)
Tien Vo
10/11/2023, 2:03 PMScenario: Request with a binary body (negative case)
When the mock server is started with interaction 7
And request 7 is made to the mock server with the following changes:
| body |
| file: spider.jpg |
Then a 500 error response is returned
And the mismatches will contain a "body" mismatch with error "Actual body [image/jpeg, 30922 bytes, starting with ffd8ffe000104a46494600010101004800480000ffe100ae4578696600004949] is not equal to the expected body [image/jpeg, 28058 bytes, starting with ffd8ffe000104a46494600010101012c012c0000ffe12db64578696600004949]"
According to document of pactffi_with_binary_file:
Will use a mime type matcher to match the body.I think the content of the binary file doesn't matter. If we change the content of the binary file, as long as the mime type doesn't change (image/jpeg), the mock server shouldn't consider this as a mismatch . The response code should be 200, not 500.
Tien Vo
10/23/2023, 1:30 AMTien Vo
10/23/2023, 1:31 AMTien Vo
10/23/2023, 1:31 AMTien Vo
10/26/2023, 2:05 AMrholshausen
10/26/2023, 2:36 AMAny matcher can be used with any generator, no restriction?Technically, yes, but they should compliment each other, otherwise they won't be useful. For instance if you set a regex matcher with
\d+
and a DateTime generator, that will not make much sense because the generated values will be different to the regex. However, a regex matcher with \d+
and a RandomInt generator will work well.rholshausen
10/26/2023, 2:38 AMAny matcher can have any example value, no restriction (as long as the example value can be JSON encoded)?The example values should represent what the matcher is matching. In the customer facing DSL, this should be validated.
Tien Vo
10/26/2023, 3:45 AMTien Vo
10/26/2023, 3:45 AMThe example values should represent what the matcher is matching. In the customer facing DSL, this should be validated.
Tien Vo
11/03/2023, 2:30 AMeachValue
matcher for query parameter. See this thread for more details:Tien Vo
11/03/2023, 3:03 AMpact:generator:type
is only optional, pact:matcher:type
is still required
• Set pact:matcher:type
to null
or integer
is the easiest way
• If I set pact:matcher:type
to something like type
, I need to also set value
, which prevent pact:generator:type
from working
• But I got these errors Could not generate a random decimal from null
• Other generator like date
, time
, datetime
or boolean
works fine because they don't validate the value
• Is this change a good idea: https://github.com/pact-foundation/pact-reference/compare/master...tienvx:pact-reference:force-generator-works-regardless-value-type?expand=1