Tests for lists/status/{list}.json

This commit is contained in:
Timothy Baldridge 2020-04-08 05:26:54 -06:00
parent 9dba806e62
commit f23f2f48c2
3 changed files with 30 additions and 0 deletions

View File

@ -4,6 +4,8 @@ using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Wabbajack.BuildServer.Model.Models;
using Wabbajack.BuildServer.Models.JobQueue;
using Wabbajack.Common;
using Wabbajack.Common.Http;
using Wabbajack.Common.StatusFeed;
@ -147,6 +149,19 @@ namespace Wabbajack.BuildServer.Test
return "http://localhost:8080/" + path;
}
protected async Task ClearJobQueue()
{
var sql = Fixture.GetService<SqlService>();
while (true)
{
var job = await sql.GetJob();
if (job == null) break;
job.Result = JobResult.Success();
await sql.FinishJob(job);
}
}
public override void Dispose()
{
Queue.Dispose();

View File

@ -21,10 +21,13 @@ namespace Wabbajack.BuildServer.Test
[Fact, Priority(1)]
public async Task CanIngestExportedInis()
{
var sql = Fixture.GetService<SqlService>();
var to = Fixture.ServerTempFolder.Combine("IniIngest");
await @"sql\DownloadStates".RelativeTo(AbsolutePath.EntryPoint).CopyDirectoryToAsync(to);
var result = await _authedClient.GetStringAsync(MakeURL("indexed_files/ingest/IniIngest"));
Assert.Equal("5", result);
await ClearJobQueue();
}
[Fact, Priority(2)]

View File

@ -6,6 +6,7 @@ using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Wabbajack.BuildServer.Model.Models;
using Wabbajack.BuildServer.Models;
using Wabbajack.BuildServer.Models.JobQueue;
using Wabbajack.BuildServer.Models.Jobs;
using Wabbajack.Common;
@ -60,9 +61,20 @@ namespace Wabbajack.BuildServer.Test
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)
{
var statusJson = await _client.GetJsonAsync<DetailedStatus>(MakeURL("lists/status/test_list.json"));
Assert.Equal(failed, statusJson.Archives.Count(a => a.IsFailing));
Assert.Equal(passed, statusJson.Archives.Count(a => !a.IsFailing));
}
private async Task<Uri> MakeModList()
{