mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 13:47:33 +08:00
Merge pull request #19411 from peppy/fix-score-transfer-test-failure
Fix potential test failure if scores are added to the beatmap which is subsequently removed
This commit is contained in:
commit
19852572b7
@ -279,12 +279,16 @@ namespace osu.Game.Tests.Database
|
|||||||
{
|
{
|
||||||
var importer = new BeatmapImporter(storage, realm);
|
var importer = new BeatmapImporter(storage, realm);
|
||||||
using var rulesets = new RealmRulesetStore(realm, storage);
|
using var rulesets = new RealmRulesetStore(realm, storage);
|
||||||
|
string removedFilename = null!;
|
||||||
|
|
||||||
using var __ = getBeatmapArchive(out string pathOriginal);
|
using var __ = getBeatmapArchive(out string pathOriginal);
|
||||||
using var _ = getBeatmapArchiveWithModifications(out string pathMissingOneBeatmap, directory =>
|
using var _ = getBeatmapArchiveWithModifications(out string pathMissingOneBeatmap, directory =>
|
||||||
{
|
{
|
||||||
// arbitrary beatmap removal
|
// arbitrary beatmap removal
|
||||||
directory.GetFiles("*.osu").First().Delete();
|
var fileToRemove = directory.GetFiles("*.osu").First();
|
||||||
|
|
||||||
|
removedFilename = fileToRemove.Name;
|
||||||
|
fileToRemove.Delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
var importBeforeUpdate = await importer.Import(new ImportTask(pathOriginal));
|
var importBeforeUpdate = await importer.Import(new ImportTask(pathOriginal));
|
||||||
@ -296,7 +300,9 @@ namespace osu.Game.Tests.Database
|
|||||||
|
|
||||||
importBeforeUpdate.PerformWrite(s =>
|
importBeforeUpdate.PerformWrite(s =>
|
||||||
{
|
{
|
||||||
var beatmapInfo = s.Beatmaps.Last();
|
// make sure not to add scores to the same beatmap that is removed in the update.
|
||||||
|
var beatmapInfo = s.Beatmaps.First(b => b.File?.Filename != removedFilename);
|
||||||
|
|
||||||
scoreTargetBeatmapHash = beatmapInfo.Hash;
|
scoreTargetBeatmapHash = beatmapInfo.Hash;
|
||||||
s.Realm.Add(new ScoreInfo(beatmapInfo, s.Realm.All<RulesetInfo>().First(), new RealmUser()));
|
s.Realm.Add(new ScoreInfo(beatmapInfo, s.Realm.All<RulesetInfo>().First(), new RealmUser()));
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user