{{ message }}
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
To test my code against a MS SQL database I spin up a test container using
testcontainersandpytestUsing this fixture in my test allow me to spin my database for tests duration and the get the connection URL.
Recently I wanted to switch to docker compose instead so I could define my services in a single place and use that same configuration for both automated tests and running my app in dev mode locally. I got my configuration in a
docker-compose.ymlin my project root. My first try was the following:At this point I got two issues:
Get the connection URL
For this one, my solution is to simply read the connection url I specified directly in my docker compose file for my app. So I add another fixture for getting my docker compose configuration.
Here, no magic anymore but this seems all good to me.
Loosing specific container classes behaviors
The second issue is that my solution is actually missing the part which wait for the database to be ready. When using
SqlServerContainerclass, it embeds a_connect()function which is called onstart()and which wait for the database to be actually ready by trying several times to run a SQL query.If I run my tests without this wait, it obviously fail at connecting to the DB.
So I tried a small hack by calling manually the
_connect()function passing the compose container asself.Unfortunately this does not work because
ComposeContainerandDockerContainerhave not the same interface.Does someone already encountered this use case? Does one already find a workaround or a pattern? Is there some improvements we could bring into the library?
Beta Was this translation helpful? Give feedback.
All reactions