1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Add test coverage of import throwing when no valid .osu files are found

This commit is contained in:
Dean Herbert 2022-06-20 16:06:22 +09:00
parent 2edd56ad17
commit e82d948acc

View File

@ -291,6 +291,42 @@ namespace osu.Game.Tests.Database
});
}
[Test]
public void TestImportDirectoryWithEmptyOsuFiles()
{
RunTestWithRealmAsync(async (realm, storage) =>
{
using var importer = new BeatmapImporter(storage, realm);
using var store = new RealmRulesetStore(realm, storage);
string? temp = TestResources.GetTestBeatmapForImport();
string extractedFolder = $"{temp}_extracted";
Directory.CreateDirectory(extractedFolder);
try
{
using (var zip = ZipArchive.Open(temp))
zip.WriteToDirectory(extractedFolder);
foreach (var file in new DirectoryInfo(extractedFolder).GetFiles("*.osu"))
{
using (file.Open(FileMode.Create))
{
// empty file.
}
}
var imported = await importer.Import(new ImportTask(extractedFolder));
Assert.IsNull(imported);
}
finally
{
Directory.Delete(extractedFolder, true);
}
});
}
[Test]
public void TestImportThenImportWithReZip()
{