1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:07:25 +08:00

Update tests to show expected score retention behaviour when saving a beatmap

This commit is contained in:
Dean Herbert 2023-07-04 14:50:50 +09:00
parent d74b1e148d
commit f30dc59afe
2 changed files with 7 additions and 8 deletions

View File

@ -431,19 +431,18 @@ namespace osu.Game.Tests.Database
await createScoreForBeatmap(realm.Realm, imported.Beatmaps.First()); await createScoreForBeatmap(realm.Realm, imported.Beatmaps.First());
Assert.That(imported.Beatmaps.First().Scores.Any());
// imitate making local changes via editor // imitate making local changes via editor
// ReSharper disable once MethodHasAsyncOverload // ReSharper disable once MethodHasAsyncOverload
realm.Write(_ => realm.Write(r =>
{ {
BeatmapInfo beatmap = imported.Beatmaps.First(); BeatmapInfo beatmap = imported.Beatmaps.First();
beatmap.Hash = "new_hash"; beatmap.Hash = "new_hash";
beatmap.ResetOnlineInfo(); beatmap.ResetOnlineInfo();
}); });
// for now, making changes to a beatmap doesn't remove the backlink from the score to the beatmap. Assert.That(!imported.Beatmaps.First().Scores.Any());
// the logic of ensuring that scores match the beatmap is upheld via comparing the hash in usages (see: https://github.com/ppy/osu/pull/22539).
// TODO: revisit when fixing https://github.com/ppy/osu/issues/24069.
Assert.That(imported.Beatmaps.First().Scores.Any());
var importedSecondTime = await importer.Import(new ImportTask(temp)); var importedSecondTime = await importer.Import(new ImportTask(temp));
@ -461,6 +460,7 @@ namespace osu.Game.Tests.Database
Assert.That(importedFirstTimeBeatmap.Hash != importedSecondTimeBeatmap.Hash); Assert.That(importedFirstTimeBeatmap.Hash != importedSecondTimeBeatmap.Hash);
Assert.That(!importedFirstTimeBeatmap.Scores.Any()); Assert.That(!importedFirstTimeBeatmap.Scores.Any());
Assert.That(importedSecondTimeBeatmap.Scores.Count() == 1); Assert.That(importedSecondTimeBeatmap.Scores.Count() == 1);
Assert.That(importedSecondTimeBeatmap.Scores.Single().BeatmapInfo, Is.EqualTo(importedSecondTimeBeatmap));
}); });
} }

View File

@ -387,10 +387,9 @@ namespace osu.Game.Tests.Database
realm.Run(r => r.Refresh()); realm.Run(r => r.Refresh());
// for now, making changes to a beatmap doesn't remove the backlink from the score to the beatmap. // making changes to a beatmap doesn't remove the score from realm, but should disassociate the beatmap.
// the logic of ensuring that scores match the beatmap is upheld via comparing the hash in usages (https://github.com/ppy/osu/pull/22539).
// TODO: revisit when fixing https://github.com/ppy/osu/issues/24069.
checkCount<ScoreInfo>(realm, 1); checkCount<ScoreInfo>(realm, 1);
Assert.That(realm.Run(r => r.All<ScoreInfo>().First().BeatmapInfo), Is.Null);
// reimport the original beatmap before local modifications // reimport the original beatmap before local modifications
var importAfterUpdate = await importer.ImportAsUpdate(new ProgressNotification(), new ImportTask(pathOnlineCopy), importBeforeUpdate.Value); var importAfterUpdate = await importer.ImportAsUpdate(new ProgressNotification(), new ImportTask(pathOnlineCopy), importBeforeUpdate.Value);