Putting it simply, my ideal scenario involves using TestContainer (right 
now, I'm using docker-compose with PostgreSQL and Flyway CLI for 
migrations) to generate JOOQ classes alongside Flyway migrations. Moreover, 
I want my tests to work with these already generated JOOQ classes. However, 
the behavior during the gradle build confuses me because, for some reason, 
before running tests, JOOQ codegen attempts to connect to the database 
again. But since the port is random, it fails to do so. Essentially, I want 
the codegen either not to rerun before the tests or to use connection data 
from TestContainer.

понедельник, 8 апреля 2024 г. в 09:35:01 UTC+3, Viktor Konev: 

> Hey everyone!
>
> I'm relatively new to JOOQ and eager to find some guidance. I'm working 
> with a stack that includes Kotlin, Spring Boot, Flyway, Testcontainers, and 
> JOOQ.
>
> Here's what I'm aiming to achieve:
>
>    1. When I run the gradle build task, I want it to start a 
>    Testcontainer with an empty PostgreSQL database, then execute Flyway 
>    migrations, and finally, have JOOQ codegen generate Java/Kotlin code.
>    2. When running tests, either keep the Testcontainer running (which 
>    might not be the best solution) or have it start only with the integration 
>    tests.
>    3. Ultimately, I want everything related to containers to shut down 
>    properly.
>
> I couldn't find a straightforward solution for this, but I did find 
> something similar using docker-compose (before moving to tests).
>
> Here's an example implementation: 
> https://github.com/Ulllie/battle/tree/feature/test-jooq-with-testcontainer/jooq
>
> BUT, the main issue arises when tests start running. JOOQ codegen tries to 
> connect to the database again and fails because it wants to connect to port 
> 5432, but in my tests, I intend to use TestContainers.
>
> This setup might be overkill, and I'm confident there could be a simpler 
> solution.
>
> The whole idea is to be able to run a single command - gradle build, 
> without any pre-existing databases, to handle migrations, generate JOOQ 
> classes, and then run integration tests. Plus, I can't figure out how to 
> separate these concepts, i.e., I want to keep the ability to run tests by 
> themselves.
>
> I realize my question is a bit sprawling, so thanks in advance for bearing 
> with me and any help you can offer
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/7171f304-be91-4672-be87-4eac76d34785n%40googlegroups.com.

Reply via email to