Skip to content

Fix AddConnectionString for tests#7327

Merged
eerhardt merged 1 commit intomainfrom
davidfowl/fix-cs-resource
Jan 30, 2025
Merged

Fix AddConnectionString for tests#7327
eerhardt merged 1 commit intomainfrom
davidfowl/fix-cs-resource

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

@davidfowl davidfowl commented Jan 30, 2025

Description

  • Calling AddConnectionString would add a parameter resource the wrap it in surrogate. That's fine if nothing looks at the "runtime type" and always looks at the contract. The testing infrastructure has a method GetConnectionStringAsync that takes a resource name and it explodes in this case since the runtime type does not implement IResourceWithConnectionString. This fixes it by implementing that adding the surrogate directly as a parameter resource.

  • Added tests

Fixes #7138

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

- Calling AddConnectionString would add a parameter resource the wrap it in surrogate. That's fine if nothing looks at the "runtime type" and always looks at the contract. The testing infrastructure has a method GetConnectionStringAsync that takes a resource name and it explodes in this case since the runtime type does not implement IResourceWithConnectionString. This fixes it by implementig that adding the surrogate directly as a parameter resource.
- Added tests
Copy link
Copy Markdown
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eerhardt eerhardt merged commit 591be49 into main Jan 30, 2025
@eerhardt eerhardt deleted the davidfowl/fix-cs-resource branch January 30, 2025 16:42
davidfowl added a commit that referenced this pull request Feb 10, 2025
- After #7327, AddConnectionStrnig was generating a value.v0 resource instead of a parameter.v0. This fixes the order of evaluation so that parameters are preferred over IResourceWithConnectionString.
eerhardt pushed a commit that referenced this pull request Feb 10, 2025
- After #7327, AddConnectionStrnig was generating a value.v0 resource instead of a parameter.v0. This fixes the order of evaluation so that parameters are preferred over IResourceWithConnectionString.
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 2, 2025
@github-actions github-actions Bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetConnectionStringAsync fails for AddConnectionString

2 participants