Hello, I have a general question regarding the imp...
# general
s
Hello, I have a general question regarding the implementation of Pact in our microservices (Java, Golang). Our requirement is to execute the provider test in the CI pipeline before the deployment step of the provider service, but we want to avoid making calls to the actual provider service deployed in some non-prod environment due to data issues. To address this, we plan to mock external API and DB calls. Now, my query is about where Pact will make the HTTP request. If Pact initiates the request to the application started in the CI pipeline programmatically, it could pose challenges because our application has numerous dependencies such as DB connections, Kafka setup, etc. Starting the application with all these dependencies configured could be problematic, especially since these dependencies are irrelevant for running the Pact provider test. In general, how do we effectively use Pact in such a situation? Additionally, is there a method for Pact to directly call the service method instead of making HTTP calls? Any insights or guidance on this matter would be greatly appreciated.
u
these dependencies are irrelevant for running the Pact provider test
that’s your answer
I’d just mock all of these. In principle CT is about “the wire” (serialisation, misunderstandings with the API, e.g. PUT vs POST vs PATCH) and not so much about the actual functionality/behaviour
s
@Ulises Cervino Understood!!. Could you please assist me in mocking dependencies within a Spring Boot application? I'm particularly focused on the bean configuration, where configuration values are retrieved from the application.properties file based on the environment. I need to set up an application.properties file containing JDBC URLs, usernames, passwords, AWS config credentials, etc. Alternatively, is it possible to skip the bean creation and start the application without it?
u
I don’t have much experience with SB, but if your app is largely driven from config I guess you can put special config so that mocks instead of actual DB drivers (or kafka clients) are initialised and injected?
s
This implies that in order to establish a JDBC connection, I must run a database instance, such as MySQL.
u
you can mock your repository too
with an in-memory implementation for instance
👍 2
s
sure thanks