Hello! I have a question about `ProviderState` gen...
# general
b
Hello! I have a question about
ProviderState
generator in C++. Will add details in thread.
If I understand correctly: •
pact_ffi
advertises that it will accept
"pact:generator:type": "ProviderState"
. • Pact specification mentions that the
ProviderState
generator is expressed like
{type": "ProviderState", "expression": "/api/user/${id}"}
Is it then safe to assume that a potentially new
FromProviderState
matcher, used in the context
Copy code
...
        .withResponseJsonBody( Object( {
                { "assetId",      FromProviderState( "${id}, "someAssetId" ) },
...
should generate
Copy code
{ "value": "someAssetId, "pact:generator:type": "ProviderState", "expression": "${id}" }
? Should there be a
type
matcher inserted as well? I can see for example that in
pact-js
, the
fromProviderState
method "Sets a type matcher and a provider state generator." I.e.:
Copy code
{ "value": "someAssetId, "pact:matcher:type":"type", "pact:generator:type": "ProviderState", "expression": "${id}" }
m
Sorry I missed this Bogdan.
You’re right, the
ProviderState
generator is not a matcher, so if you need it to also constrain the types, you need to combine matching rules: https://docs.pact.io/implementation_guides/rust/pact_ffi/integrationjson#supporting-multiple-matching-rules