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 @@ -25,6 +25,10 @@ public sealed class TestingWebApplicationFactory : WebApplicationFactory<Program
{
private readonly PostgresTestDatabase _database = new();

// WebApplicationFactory adds each client to a List with no lock, and the tests create their clients in parallel.
// Two adds at the same time can lose a client or leave a null in the list, and DisposeAsync then throws.
private readonly Lock _clientLock = new();

/// <summary>
/// The machine client that the test server lets manage all tenants. It also reads the rows of all tenants.
/// </summary>
Expand Down Expand Up @@ -125,6 +129,12 @@ public async Task InitializeAsync()
Instance = this;
}

public new HttpClient CreateClient()
{
lock (_clientLock)
return base.CreateClient();
}

public override async ValueTask DisposeAsync()
{
await base.DisposeAsync();
Expand Down
Loading