1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Add failing test coverage for not attempting to upgrade custom ruleset scores

This commit is contained in:
Bartłomiej Dach 2024-01-08 21:51:01 +01:00
parent 70ba5dd0d3
commit 67df7b33fb
No known key found for this signature in database
2 changed files with 33 additions and 1 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -182,9 +183,38 @@ namespace osu.Game.Tests.Database
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000002));
}
[Test]
public void TestCustomRulesetScoreNotSubjectToUpgrades([Values] bool available)
{
RulesetInfo rulesetInfo = null!;
ScoreInfo scoreInfo = null!;
TestBackgroundDataStoreProcessor processor = null!;
AddStep("Add unavailable ruleset", () => Realm.Write(r => r.Add(rulesetInfo = new RulesetInfo
{
ShortName = Guid.NewGuid().ToString(),
Available = available
})));
AddStep("Add score for unavailable ruleset", () => Realm.Write(r => r.Add(scoreInfo = new ScoreInfo(
ruleset: rulesetInfo,
beatmap: r.All<BeatmapInfo>().First())
{
TotalScoreVersion = 30000001
})));
AddStep("Run background processor", () => Add(processor = new TestBackgroundDataStoreProcessor()));
AddUntilStep("Wait for completion", () => processor.Completed);
AddAssert("Score not marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.BackgroundReprocessingFailed), () => Is.False);
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000001));
}
public partial class TestBackgroundDataStoreProcessor : BackgroundDataStoreProcessor
{
protected override int TimeToSleepDuringGameplay => 10;
public bool Completed => ProcessingTask.IsCompleted;
}
}
}

View File

@ -28,6 +28,8 @@ namespace osu.Game
/// </summary>
public partial class BackgroundDataStoreProcessor : Component
{
protected Task ProcessingTask = null!;
[Resolved]
private RulesetStore rulesetStore { get; set; } = null!;
@ -61,7 +63,7 @@ namespace osu.Game
{
base.LoadComplete();
Task.Factory.StartNew(() =>
ProcessingTask = Task.Factory.StartNew(() =>
{
Logger.Log("Beginning background data store processing..");