Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@ public class AppHostTests(AspireIntegrationTestFixture<Projects.CommunityToolkit
public async Task SurrealResourceStartsAndRespondsOk()
{
const string resourceName = "surreal";
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);
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
Assert.Equal(KnownResourceStates.Running, evt.Snapshot.State);
Assert.Equal(KnownResourceStates.Running, evt.Snapshot.State?.Text);

Copilot uses AI. Check for mistakes.

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

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

Comment on lines +23 to 33
Copy link

Copilot AI Mar 27, 2026

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.OK, response.StatusCode);
Assert.Equal(HttpStatusCode.RedirectKeepVerb, response.StatusCode);
Assert.Equal("https://surrealdb.com/surrealist", response.Headers.Location?.AbsoluteUri);
Copy link

Copilot AI Mar 27, 2026

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 All @@ -35,7 +44,7 @@ public async Task ApiServiceStartsAndRespondsOk()

var todoResponse = await httpClient.GetAsync("/api/todo");
Assert.Equal(HttpStatusCode.OK, todoResponse.StatusCode);

var initResponse = await httpClient.PostAsync("/init", null);
Assert.Equal(HttpStatusCode.OK, initResponse.StatusCode);

Expand Down
Loading