Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to pass arbitrary flyway config to @FlywayTest #367

Open
mohamnag opened this issue Apr 27, 2023 · 3 comments
Open

A way to pass arbitrary flyway config to @FlywayTest #367

mohamnag opened this issue Apr 27, 2023 · 3 comments

Comments

@mohamnag
Copy link

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?

@radcortez
Copy link
Owner

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?

@mohamnag
Copy link
Author

mohamnag commented May 5, 2023

well having a file separate from the test is an impractical solution. I have used wiremock with this setup and soon two problems emerge:

  1. becomes hard to understand the setup of test as config relies separately in a different file (the properties file)
  2. becomes hard to change those config files as people start reusing one 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?

@radcortez
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants