How do use an outer resource for creating inner resources?
For my integration tests with postgres I'm using the module `TestContainers.HSpec` that fires up a docker image with postgres and returns a `ConnectInfo` with the port, db, etc... For that I'm wrapping my tests with:
```haskell
aroundAll (TH.withContainers containers) $
describe "The Account Repo" do
itWithOuter "creates users" \repo -> do
.....
```
Then I would like on every test, to truncate all tables in the DB, so I need that the `before` and/or `before_` know something about the outer resource in order to create a connection to DB, and perform the "TRUNCATE" command, but the outer and inner resources seem to only new about each other at the test itself, so any initialization code (ie the Truncate) should be repeated on each test instead of being placed in a single `before` function.
What I'm missing here? Is there a proper way to use the outer to create/use an inner resource?
关闭于 2024-10-18 5 条评论