Open mohamnag opened 1 year ago
My recommendation is to have something that accepts a properties
file path from the classpath and then load it in the Flyway
instance (like we already do with additionalLocations
).
Would you like to submit a PR?
well having a file separate from the test is an impractical solution. I have used wiremock with this setup and soon two problems emerge:
properties
file)properties
file from multiple tests.so what I was thinking of, is a kind of passing config like following pseudo-code:
@FlywayTest(
value = @DataSource(SomeDataSourceProvider.class),
additionalLocations = {"classpath:some/sql/files/"},
config = {
"key"="value",
"createSchemas"="false",
}
)
a better variation is that a config file is also allowed to be passed in (mainly for common config parts) and that additional key value pair defined directly on the annotation just overrides things that should be changed for specific test. for example:
@FlywayTest(
value = @DataSource(SomeDataSourceProvider.class),
configFile = "classpath:/some/dir/flyway.conf"
configOverride = {
"key"="value",
"createSchemas"="false",
}
)
I could go on and prepare something for this case as it also matches my usage pattern. WDYT?
Well, I want to avoid translating all the config into the annotation. With a file, you would only need a single parameter in the annotation, and it would be easier to hand over to the Flyway instance. I guess that we could add a repeatable @Config
annotation with key / value.
I have seen other issues regarding using a file or environment variables to pass configurations to flyway. this might work in some scenarios but in specific cases they are not practical or need much additional effort. like when one has many tests which each need to be configured differently.
A very effective solution (which can also be potentially done very easily) is that one can set an arbitrary map on the
@FlywayTest
to just pass configurations to the instance that is created later. What do you think?