Srijan Choudhary
08/15/2023, 6:26 AMPactRef = pact:v4(<<"myapp">>, <<"animal_service">>),
AnimalObject = #{<<"name">> => <<"Mary">>, <<"type">> => <<"alligator">>},
{ok, Port} = pact:interaction(PactRef,
#{
given => <<"an alligator with the name Mary exists">>,
upon_receiving => <<"a request to GET an animal: Mary">>,
with_request => #{
method => <<"GET">>,
path => <<"/animals/Mary">>
},
will_respond_with => #{
status => 200,
headers => #{
<<"Content-Type">> => <<"application/json">>
},
body => thoas:encode(AnimalObject)
}
}),
?assertMatch({ok, AnimalObject}, animal_service_interface:get_animal(Port, "Mary")),
{ok, matched} = pact:verify(PactRef),
pact:write(PactRef, <<"./pacts">>),
pact:cleanup(PactRef).
Priyaranjan Mudliar
08/15/2023, 2:12 PMYousaf Nabi (pactflow.io)