1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 19:22:56 +08:00

Fix realm potentially not being refreshed in time for test asserts in BeatmapImporterTests

As seen at https://github.com/ppy/osu/runs/5659368512?check_suite_focus=true

Went through every usage of `.Import` and added either an
`EnsureLoaded`, or where that provides too many checks, an explicit
`realm.Refresh()`.
This commit is contained in:
Dean Herbert 2022-03-24 12:53:50 +09:00
parent 3b97de04b7
commit 4d0b4c2541

View File

@ -147,7 +147,10 @@ namespace osu.Game.Tests.Database
Live<BeatmapSetInfo>? imported;
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
{
imported = await importer.Import(reader);
EnsureLoaded(realm.Realm);
}
Assert.AreEqual(1, realm.Realm.All<BeatmapSetInfo>().Count());
@ -510,6 +513,8 @@ namespace osu.Game.Tests.Database
new ImportTask(zipStream, string.Empty)
);
realm.Run(r => r.Refresh());
checkBeatmapSetCount(realm.Realm, 0);
checkBeatmapCount(realm.Realm, 0);
@ -565,6 +570,8 @@ namespace osu.Game.Tests.Database
{
}
EnsureLoaded(realm.Realm);
checkBeatmapSetCount(realm.Realm, 1);
checkBeatmapCount(realm.Realm, 12);
@ -726,6 +733,8 @@ namespace osu.Game.Tests.Database
var imported = importer.Import(toImport);
realm.Run(r => r.Refresh());
Assert.NotNull(imported);
Debug.Assert(imported != null);
@ -891,6 +900,8 @@ namespace osu.Game.Tests.Database
string? temp = TestResources.GetTestBeatmapForImport();
await importer.Import(temp);
EnsureLoaded(realm.Realm);
// Update via the beatmap, not the beatmap info, to ensure correct linking
BeatmapSetInfo setToUpdate = realm.Realm.All<BeatmapSetInfo>().First();