mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Finish up the list validation tests
This commit is contained in:
parent
ce14a60e6e
commit
ccb6f93901
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HtmlAgilityPack;
|
||||
using Wabbajack.BuildServer.Model.Models;
|
||||
using Wabbajack.BuildServer.Models;
|
||||
using Wabbajack.BuildServer.Models.JobQueue;
|
||||
@ -41,6 +42,45 @@ namespace Wabbajack.BuildServer.Test
|
||||
var modlists = await MakeModList();
|
||||
Consts.ModlistMetadataURL = modlists.ToString();
|
||||
Utils.Log("Updating modlists");
|
||||
await RevalidateLists();
|
||||
|
||||
Utils.Log("Checking validated results");
|
||||
var data = await ModlistMetadata.LoadFromGithub();
|
||||
Assert.Single(data);
|
||||
Assert.Equal(0, data.First().ValidationSummary.Failed);
|
||||
Assert.Equal(1, data.First().ValidationSummary.Passed);
|
||||
|
||||
await CheckListFeeds(0, 1);
|
||||
|
||||
Utils.Log("Break List");
|
||||
var archive = "test_archive.txt".RelativeTo(Fixture.ServerPublicFolder);
|
||||
await archive.MoveToAsync(archive.WithExtension(new Extension(".moved")), true);
|
||||
|
||||
await RevalidateLists();
|
||||
|
||||
data = await ModlistMetadata.LoadFromGithub();
|
||||
Assert.Single(data);
|
||||
Assert.Equal(1, data.First().ValidationSummary.Failed);
|
||||
Assert.Equal(0, data.First().ValidationSummary.Passed);
|
||||
|
||||
await CheckListFeeds(1, 0);
|
||||
|
||||
Utils.Log("Fix List");
|
||||
await archive.WithExtension(new Extension(".moved")).MoveToAsync(archive, false);
|
||||
|
||||
await RevalidateLists();
|
||||
|
||||
data = await ModlistMetadata.LoadFromGithub();
|
||||
Assert.Single(data);
|
||||
Assert.Equal(0, data.First().ValidationSummary.Failed);
|
||||
Assert.Equal(1, data.First().ValidationSummary.Passed);
|
||||
|
||||
await CheckListFeeds(0, 1);
|
||||
|
||||
}
|
||||
|
||||
private async Task RevalidateLists()
|
||||
{
|
||||
var result = await AuthorAPI.UpdateServerModLists();
|
||||
Assert.NotNull(result);
|
||||
|
||||
@ -54,16 +94,6 @@ namespace Wabbajack.BuildServer.Test
|
||||
|
||||
var jobResult = await job.Payload.Execute(sql, settings);
|
||||
Assert.Equal(JobResultType.Success, jobResult.ResultType);
|
||||
|
||||
Utils.Log("Checking validated results");
|
||||
var data = await ModlistMetadata.LoadFromGithub();
|
||||
|
||||
Assert.Single(data);
|
||||
Assert.Equal(0, data.First().ValidationSummary.Failed);
|
||||
Assert.Equal(1, data.First().ValidationSummary.Passed);
|
||||
|
||||
await CheckListFeeds(0, 1);
|
||||
|
||||
}
|
||||
|
||||
private async Task CheckListFeeds(int failed, int passed)
|
||||
@ -73,6 +103,12 @@ namespace Wabbajack.BuildServer.Test
|
||||
Assert.Equal(passed, statusJson.Archives.Count(a => !a.IsFailing));
|
||||
|
||||
|
||||
var statusHtml = await _client.GetHtmlAsync(MakeURL("lists/status/test_list.html"));
|
||||
Assert.NotEmpty(statusHtml.DocumentNode.Descendants().Where(n => n.InnerHtml == $"Failed ({failed}):"));
|
||||
Assert.NotEmpty(statusHtml.DocumentNode.Descendants().Where(n => n.InnerHtml == $"Passed ({passed}):"));
|
||||
|
||||
var statusRss = await _client.GetHtmlAsync(MakeURL("lists/status/test_list/broken.rss"));
|
||||
Assert.Equal(failed, statusRss.DocumentNode.SelectNodes("//item")?.Count ?? 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using HtmlAgilityPack;
|
||||
|
||||
namespace Wabbajack.Common.Http
|
||||
{
|
||||
@ -104,5 +105,13 @@ namespace Wabbajack.Common.Http
|
||||
var result = await GetStringAsync(s);
|
||||
return result.FromJsonString<T>();
|
||||
}
|
||||
|
||||
public async Task<HtmlDocument> GetHtmlAsync(string s)
|
||||
{
|
||||
var body = await GetStringAsync(s);
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(body);
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.23" />
|
||||
<PackageReference Include="ini-parser-netstandard" Version="2.5.2" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
|
Loading…
Reference in New Issue
Block a user