Add explicit write transactions and deterministic ordering tests

This commit is contained in:
2026-02-07 01:16:07 +01:00
parent 0d60108036
commit 35d842d6ee
4 changed files with 26 additions and 25 deletions

View File

@@ -365,28 +365,15 @@ public class SuggestionTests
var client = factory.CreateClientWithCookies();
await client.RegisterAsync("mine");
await client.PostAsJsonAsync("/api/suggestions", new
var secondId = await client.CreateSuggestionAsync("Second");
var thirdId = await client.CreateSuggestionAsync("Third");
await factory.WithDbContextAsync(async db =>
{
Name = "Second",
Genre = (string?)null,
Description = (string?)null,
ScreenshotUrl = (string?)null,
YoutubeUrl = (string?)null,
GameUrl = (string?)null,
MinPlayers = (int?)null,
MaxPlayers = (int?)null
});
await Task.Delay(10);
await client.PostAsJsonAsync("/api/suggestions", new
{
Name = "Third",
Genre = (string?)null,
Description = (string?)null,
ScreenshotUrl = (string?)null,
YoutubeUrl = (string?)null,
GameUrl = (string?)null,
MinPlayers = (int?)null,
MaxPlayers = (int?)null
var second = await db.Suggestions.FindAsync(secondId);
var third = await db.Suggestions.FindAsync(thirdId);
second!.CreatedAt = DateTimeOffset.UtcNow.AddMinutes(-1);
third!.CreatedAt = DateTimeOffset.UtcNow;
await db.SaveChangesAsync();
});
var mine = await client.GetFromJsonAsync<List<JsonElement>>("/api/suggestions/mine");
@@ -572,11 +559,13 @@ public class SuggestionTests
await client.RegisterAsync("owner");
var id1 = await client.CreateSuggestionAsync("Alpha");
await Task.Delay(10);
var id2 = await client.CreateSuggestionAsync("Beta");
await factory.WithDbContextAsync(async db =>
{
var alpha = await db.Suggestions.FindAsync(id1);
var beta = await db.Suggestions.FindAsync(id2);
alpha!.CreatedAt = DateTimeOffset.UtcNow.AddMinutes(-1);
beta!.CreatedAt = DateTimeOffset.UtcNow;
beta!.ParentSuggestionId = id1;
await db.SaveChangesAsync();
});