Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Actually, we can use a HTTP probe but don't follow the redirect
  • Loading branch information
aaronpowell committed Mar 27, 2026
commit 1c3b800a63e9d0c9475651107df5f32b5731010e
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,23 @@ public class AppHostTests(AspireIntegrationTestFixture<Projects.CommunityToolkit
public async Task SurrealResourceStartsAndRespondsOk()
{
const string resourceName = "surreal";
var evt = await fixture.ResourceNotificationService.WaitForResourceHealthyAsync(resourceName).WaitAsync(TimeSpan.FromMinutes(1));
await fixture.ResourceNotificationService.WaitForResourceHealthyAsync(resourceName).WaitAsync(TimeSpan.FromMinutes(1));

Assert.Equal(KnownResourceStates.Running, evt.Snapshot.State);
var tcpUri = fixture.GetEndpoint(resourceName, "tcp");
var baseUri = new Uri(tcpUri.AbsoluteUri.Replace("tcp://", "http://"));
var handler = new HttpClientHandler
{
AllowAutoRedirect = false
};
var httpClient = new HttpClient(handler)
{
BaseAddress = baseUri
};

var response = await httpClient.GetAsync("/");

Comment on lines +23 to 33

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Assert.Equal(HttpStatusCode.RedirectKeepVerb, response.StatusCode);
Assert.Equal("https://surrealdb.com/surrealist", response.Headers.Location?.AbsoluteUri);

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
Assert.Equal("https://surrealdb.com/surrealist", response.Headers.Location?.AbsoluteUri);
var redirectLocation = response.Headers.Location;
Assert.NotNull(redirectLocation);
Assert.Equal("surrealdb.com", redirectLocation.Host);

Copilot uses AI. Check for mistakes.
}

[Fact]
Expand Down