Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1237Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1237" |
Minimum allowed line rate is |
There was a problem hiding this comment.
Pull request overview
Updates the SurrealDB hosting integration tests to avoid following SurrealDB’s HTTP redirect behavior, which now interferes with automated assertions.
Changes:
- Capture the “resource healthy” event and add an assertion on the resource snapshot state.
- Disable auto-redirects in the test HTTP client and assert redirect status +
Locationheader for/. - Minor whitespace cleanup in the API service test.
| await fixture.ResourceNotificationService.WaitForResourceHealthyAsync(resourceName).WaitAsync(TimeSpan.FromMinutes(1)); | ||
| var evt = await fixture.ResourceNotificationService.WaitForResourceHealthyAsync(resourceName).WaitAsync(TimeSpan.FromMinutes(1)); | ||
|
|
||
| Assert.Equal(KnownResourceStates.Running, evt.Snapshot.State); |
There was a problem hiding this comment.
evt.Snapshot.State is a ResourceStateSnapshot (see other tests using .State?.Text), so comparing it directly to KnownResourceStates.Running will never match (and may be a type mismatch depending on overload resolution). Compare against evt.Snapshot.State?.Text (or assert evt.Snapshot.HealthStatus is Healthy if that’s what you want to validate here).
| Assert.Equal(KnownResourceStates.Running, evt.Snapshot.State); | |
| Assert.Equal(KnownResourceStates.Running, evt.Snapshot.State?.Text); |
| var handler = new HttpClientHandler | ||
| { | ||
| AllowAutoRedirect = false | ||
| }; | ||
| var httpClient = new HttpClient(handler) | ||
| { | ||
| BaseAddress = baseUri | ||
| }; | ||
|
|
||
| var response = await httpClient.GetAsync("/"); | ||
|
|
There was a problem hiding this comment.
The HttpClient (and its handler) isn’t disposed. In this repo some tests use using var httpClient (and using var response) to avoid socket/resource leaks during larger test runs. Consider disposing the client (and response) here as well.
|
|
||
| Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
| Assert.Equal(HttpStatusCode.RedirectKeepVerb, response.StatusCode); | ||
| Assert.Equal("https://surrealdb.com/surrealist", response.Headers.Location?.AbsoluteUri); |
There was a problem hiding this comment.
Asserting the exact redirect target (https://surrealdb.com/surrealist) makes the test brittle to upstream website changes (which is the root cause described in the PR). To keep the test stable, consider asserting only that the response is a redirect and that the Location header points to surrealdb.com (or is non-null), rather than matching the full absolute URI.
| Assert.Equal("https://surrealdb.com/surrealist", response.Headers.Location?.AbsoluteUri); | |
| var redirectLocation = response.Headers.Location; | |
| Assert.NotNull(redirectLocation); | |
| Assert.Equal("surrealdb.com", redirectLocation.Host); |
Closes #I was too lazy to log
SurrealDB's endpoint, when hit by HTTP, will direct to their website, and it doesn't like getting sent there from automated tests anymore, so updating how we assert.
PR Checklist
Other information