Ran Abitbul
06/11/2023, 2:33 PMNoPactsFoundException: No Pact files were found to verify exception.
I have added the @IgnoreNoPactsToVerify annotation, and added a null check to the PactVerificationContext
Here is the class:
@Provider("${PACT_PROVIDER_NAME:}")
@PactBroker(url = "${PACT_BROKER_URL:}")
@IgnoreNoPactsToVerify
@RequiredArgsConstructor
@Slf4j
public class PactVerificationTests {
@State("HAS_USERS")
public void hasUsersState(Map<String, Object> params) throws URISyntaxException, IOException {
...
}
@BeforeEach
void beforeEachInteraction(PactVerificationContext ctx) throws MalformedURLException {
if(ctx == null){
log.debug("Null PactVerificationContext received, no pacts to verify");
return;
}
var interaction = ctx.getInteraction();
var states = interaction.getProviderStates();
if (states.size() > 1) {
throw new AssertionError("Only 0 or 1 states are currently supported per interaction");
}
var targetUrl = Config.testedAppURL();
ctx.setTarget(HttpTestTarget.fromUrl(new URL(targetUrl)));
}
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext ctx) {
if(ctx == null){
log.debug("Null PactVerificationContext received, no pacts to verify");
return;
}
ctx.verifyInteraction();
}
}
The only selector I am using is {"mainBranch": true}, but as I said - this provider does not have any consumers yet. How could I overcome this exception?
Thanks :)Boris
06/12/2023, 3:12 AMBoris
06/12/2023, 3:14 AMRan Abitbul
06/12/2023, 6:04 AMBoris
06/12/2023, 6:31 AMRan Abitbul
06/12/2023, 11:16 AMYousaf Nabi (pactflow.io)
I consider a provider with no consumers a valid statePact doesnโt
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
> pact-broker can-i-deploy --pacticipant provider-foo --version foo
Pacticipant provider-foo not foundRan Abitbul
06/12/2023, 12:09 PMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Ran Abitbul
06/12/2023, 12:17 PMcreate-or-update-pacticipant call.Yousaf Nabi (pactflow.io)
Ran Abitbul
06/12/2023, 12:41 PM