Пример #1
0
        protected override async Task <ExitCode> Run()
        {
            var hash = Hash.FromBase64(NoPatchHash);

            Console.WriteLine(await AuthorAPI.NoPatch(hash, Rationale));
            return(ExitCode.Ok);
        }
Пример #2
0
        public async Task CanIndexAndUpdateFiles()
        {
            var _sql = Fixture.GetService <SqlService>();

            await using var conn = await _sql.Open();

            await conn.ExecuteAsync("DELETE FROM dbo.NoPatch");

            var settings = Fixture.GetService <AppSettings>();

            settings.ValidateModUpgrades = false;
            var validator = Fixture.GetService <ListValidator>();
            var nonNexus  = Fixture.GetService <NonNexusDownloadValidator>();
            var modLists  = await MakeModList("CanIndexAndUpdateFiles.txt");

            Consts.ModlistMetadataURL = modLists.ToString();


            var listDownloader = Fixture.GetService <ModListDownloader>();
            var downloader     = Fixture.GetService <ArchiveDownloader>();
            var archiver       = Fixture.GetService <ArchiveMaintainer>();
            var patcher        = Fixture.GetService <PatchBuilder>();

            patcher.NoCleaning = true;

            var sql         = Fixture.GetService <SqlService>();
            var oldFileData = Encoding.UTF8.GetBytes("Cheese for Everyone!");
            var newFileData = Encoding.UTF8.GetBytes("Forks for Everyone!");
            var oldDataHash = oldFileData.xxHash();
            var newDataHash = newFileData.xxHash();

            var oldArchive = new Archive(new NexusDownloader.State {
                Game = Game.Enderal, ModID = 42, FileID = 10
            })
            {
                Size = oldFileData.Length,
                Hash = oldDataHash
            };
            var newArchive = new Archive(new NexusDownloader.State {
                Game = Game.Enderal, ModID = 42, FileID = 11
            })
            {
                Size = newFileData.Length,
                Hash = newDataHash
            };

            await IngestData(archiver, oldFileData);
            await IngestData(archiver, newFileData);

            await sql.EnqueueDownload(oldArchive);

            var oldDownload = await sql.GetNextPendingDownload();

            await oldDownload.Finish(sql);

            await sql.EnqueueDownload(newArchive);

            var newDownload = await sql.GetNextPendingDownload();

            await newDownload.Finish(sql);


            await Assert.ThrowsAsync <HttpException>(async() => await ClientAPI.GetModUpgrade(oldArchive, newArchive, TimeSpan.Zero, TimeSpan.Zero));

            Assert.True(await patcher.Execute() > 1);

            Assert.Equal(new Uri("https://test-files.wabbajack.org/79223277e28e1b7b_3286c571d95f5666"), await ClientAPI.GetModUpgrade(oldArchive, newArchive, TimeSpan.Zero, TimeSpan.Zero));

            Assert.Equal("Purged", await AuthorAPI.NoPatch(oldArchive.Hash, "Testing NoPatch"));

            await Assert.ThrowsAsync <HttpException>(async() => await ClientAPI.GetModUpgrade(oldArchive, newArchive, TimeSpan.Zero, TimeSpan.Zero));

            Assert.True(await sql.IsNoPatch(oldArchive.Hash));
        }