mirror of
https://github.com/ppy/osu
synced 2024-12-24 15:53:37 +00:00
Add failing test coverage for not attempting to upgrade custom ruleset scores
This commit is contained in:
parent
70ba5dd0d3
commit
67df7b33fb
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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..");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user