mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Write a test to verify file download renaming behavior
This commit is contained in:
parent
b1eefa6a41
commit
05eb427ce5
@ -240,7 +240,7 @@ namespace Wabbajack.Lib
|
||||
await DownloadMissingArchives(missing);
|
||||
}
|
||||
|
||||
private async Task DownloadMissingArchives(List<Archive> missing, bool download = true)
|
||||
public async Task DownloadMissingArchives(List<Archive> missing, bool download = true)
|
||||
{
|
||||
if (download)
|
||||
{
|
||||
@ -270,7 +270,7 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
return await DownloadArchive(archive, download);
|
||||
return await DownloadArchive(archive, download, outputPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -466,6 +466,78 @@ namespace Wabbajack.Test
|
||||
var entries = archive.Entries.Select(e => e.FullName).ToList();
|
||||
CollectionAssert.AreEqual(entries, new List<string> {@"Data\TestCK.esp", @"Data\TestCK.ini"});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tests that files from different sources don't overwrite eachother when downloaded by AInstaller
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[TestMethod]
|
||||
public async Task DownloadRenamingTests()
|
||||
{
|
||||
// Test mode off for this test
|
||||
Consts.TestMode = false;
|
||||
|
||||
|
||||
var inia = $@"[General]
|
||||
gameName={Game.SkyrimSpecialEdition.MetaData().MO2ArchiveName}
|
||||
gameFile=Data/Update.esm";
|
||||
|
||||
var statea = (GameFileSourceDownloader.State)await DownloadDispatcher.ResolveArchive(inia.LoadIniString());
|
||||
|
||||
var inib = $@"[General]
|
||||
gameName={Game.SkyrimSpecialEdition.MetaData().MO2ArchiveName}
|
||||
gameFile=Data/Skyrim.esm";
|
||||
var stateb = (GameFileSourceDownloader.State)await DownloadDispatcher.ResolveArchive(inib.LoadIniString());
|
||||
|
||||
var archivesa = new List<Archive>()
|
||||
{
|
||||
new Archive {Hash = statea.Hash, Name = "Download.esm", State = statea}
|
||||
};
|
||||
|
||||
var archivesb = new List<Archive>()
|
||||
{
|
||||
new Archive {Hash = stateb.Hash, Name = "Download.esm", State = stateb}
|
||||
};
|
||||
|
||||
if (Directory.Exists("DownloadTests"))
|
||||
Utils.DeleteDirectory("DownloadTests");
|
||||
Directory.CreateDirectory("DownloadTests");
|
||||
|
||||
var inst = new TestInstaller(null, null, null, "DownloadTests", null);
|
||||
|
||||
await inst.DownloadMissingArchives(archivesa, true);
|
||||
await inst.DownloadMissingArchives(archivesb, true);
|
||||
|
||||
CollectionAssert.AreEqual(Directory.EnumerateFiles("DownloadTests").Select(Path.GetFileName).OrderBy(a => a).ToArray(),
|
||||
new string[]
|
||||
{
|
||||
@"Download.esm",
|
||||
@"Download.esm.xxHash",
|
||||
@"Download_f80ee6d109516018308f62e2c862b7f061987ac4a8c2327a101ac6b8f80ec4ae_.esm",
|
||||
@"Download_f80ee6d109516018308f62e2c862b7f061987ac4a8c2327a101ac6b8f80ec4ae_.esm.xxHash"
|
||||
}.OrderBy(a => a).ToArray());
|
||||
|
||||
Consts.TestMode = true;
|
||||
|
||||
}
|
||||
|
||||
class TestInstaller : AInstaller
|
||||
{
|
||||
public TestInstaller(string archive, ModList modList, string outputFolder, string downloadFolder, SystemParameters parameters) : base(archive, modList, outputFolder, downloadFolder, parameters)
|
||||
{
|
||||
ConfigureProcessor(1, new Subject<int>().StartWith(1));
|
||||
}
|
||||
|
||||
protected override Task<bool> _Begin(CancellationToken cancel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override ModManager ModManager { get => ModManager.MO2; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user