micronaut-data
micronaut-data copied to clipboard
Create a way to disable Micronaut Data programmatically
see: https://github.com/micronaut-projects/micronaut-data/discussions/2856#discussioncomment-9135627
What exactly do you want to disable?
What exactly do you want to disable?
see the linked discussion.
A user with configuration such as application.properties
datasources.default.db-type=mysql
datasources.default.dialect=MYSQL
micronaut.application.name=demo
datasources.default.schema-generate=CREATE_DROP
datasources.default.driver-class-name=com.mysql.cj.jdbc.Driver
Should be able to write a functional test unrelated to persistence and don't waste time trying to setup the persistence logic.
Users need to be able to annotate a test with something like:
@Property(name = "data.enabled=false")
@MicronautTest
MyFunctionalTestUnrelatedToPersistenceTest
We added for example the ability to disable JPA:
https://micronaut-projects.github.io/micronaut-sql/5.6.0/guide/#hibernate-disable
Depends if you want to disable some implementation based on it JDBC / Hibernate Or disable a datasource completely
Depends if you want to disable some implementation based on it JDBC / Hibernate Or disable a datasource completely
I think disabling a datasource completely.
Then it should be implemented in sql module. BasicJdbcConfiguration should implement Toggleable, but I'm not sure if we do support excluding the bean definitions by default if the interface is implemented.
Adding to what Sergio has mentioned: Yes please, we need to disable a DataSource completely.
Use case: I wanted to test a mapper interaction with a service to verify that everything works well together, but the app uses a DB and I don't really want to set up one just for that test (or the couple of tests not related to a DB).
Thanks!
Done in micronaut-sql by https://github.com/micronaut-projects/micronaut-sql/pull/1323