Unable to Access Postgres with DistributedApplicationTestingBuilder #4657
Replies: 2 comments 7 replies
-
You have to Start the application before you can get the connection string. |
Beta Was this translation helpful? Give feedback.
-
A little more context here: The aspire app host after started doesn't have any of the connection strings in the Configuration at all. It does if you run it normally. This is running from Rider with the Aspire plugin installed. We've also tried running the tests from Vs code with the same results. We're a mac shop so no ability to run in VS.net. Docker desktop shows postgres running (and pg admin works fine, and shows that the migration job that we have run on apphost startup runs), so it appears thatDistributedApplicationTestingBuilder is not doing the connection string injection properly. |
Beta Was this translation helpful? Give feedback.
-
Summary
I can't access Postgres for seeding / data setup in integration tests for Tests using Aspire
Detail
I'm starting to write integration tests in a new aspire project. I'm trying to add some test data to the project before I run the test code and make my assertions.
The ConnectionStrings I have setup in my appsettings.json files are placeholders and I use aspire to build them at Runtime. When I try and access my ConnectionStrings, I get the following error
I see that there's a slightly different way to write tests that uses DistrubutedApplication directly instead of
DistributedApplicationTestingBuilder
. This looks like it would work for what I need, but wasn't sure if there's some unseen issue with using that directly.I may be missing a very core / fundamental setup thing about dotnet as I'm still learning this stack and aspire in general.
Question
FWIW Here's my test setup
Beta Was this translation helpful? Give feedback.
All reactions