Skip to content

Commit

Permalink
Add failing test coverage of adding a file to a detached beatmap acro…
Browse files Browse the repository at this point in the history
…ss threads
  • Loading branch information
peppy committed May 10, 2022
1 parent 2e774fb commit 87f6f74
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions osu.Game.Tests/Database/BeatmapImporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,37 @@ public void TestUpdateDetachedBeatmapSet()
});
}

[Test]
public void TestAddFileToAsyncImportedBeatmap()
{
RunTestWithRealm((realm, storage) =>
{
BeatmapSetInfo? detachedSet = null;

using (var importer = new BeatmapModelManager(realm, storage))
using (new RealmRulesetStore(realm, storage))
{
Task.Run(async () =>
{
Live<BeatmapSetInfo>? beatmapSet;

using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
// ReSharper disable once AccessToDisposedClosure
beatmapSet = await importer.Import(reader);

Assert.NotNull(beatmapSet);
Debug.Assert(beatmapSet != null);

// Intentionally detach on async thread as to not trigger a refresh on the main thread.
beatmapSet.PerformRead(s => detachedSet = s.Detach());
}).WaitSafely();

Debug.Assert(detachedSet != null);
importer.AddFile(detachedSet, new MemoryStream(), "test");
}
});
}

[Test]
public void TestImportBeatmapThenCleanup()
{
Expand Down

0 comments on commit 87f6f74

Please sign in to comment.