mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Verified that nexus entries are purged by the updates job
This commit is contained in:
parent
c4ef7f3be1
commit
26a42d3ceb
53
Wabbajack.BuildServer.Test/JobTests.cs
Normal file
53
Wabbajack.BuildServer.Test/JobTests.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.BuildServer.Model.Models;
|
||||
using Wabbajack.BuildServer.Models.JobQueue;
|
||||
using Wabbajack.BuildServer.Models.Jobs;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Wabbajack.BuildServer.Test
|
||||
{
|
||||
|
||||
public class JobTests : ABuildServerSystemTest
|
||||
{
|
||||
public JobTests(ITestOutputHelper output, SingletonAdaptor<BuildServerFixture> fixture) : base(output, fixture)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CanRunNexusUpdateJob()
|
||||
{
|
||||
var sql = Fixture.GetService<SqlService>();
|
||||
|
||||
var oldRecords = await NexusUpdatesFeeds.GetUpdates();
|
||||
foreach (var record in oldRecords)
|
||||
{
|
||||
await sql.AddNexusModInfo(record.Game, record.ModId, DateTime.UtcNow - TimeSpan.FromDays(1),
|
||||
new ModInfo());
|
||||
await sql.AddNexusModFiles(record.Game, record.ModId, DateTime.UtcNow - TimeSpan.FromDays(1),
|
||||
new NexusApiClient.GetModFilesResponse());
|
||||
|
||||
Assert.NotNull(await sql.GetModFiles(record.Game, record.ModId));
|
||||
Assert.NotNull(await sql.GetNexusModInfoString(record.Game, record.ModId));
|
||||
}
|
||||
|
||||
Utils.Log($"Ingested {oldRecords.Count()} nexus records");
|
||||
|
||||
// We know this will load the same records as above, but the date will be more recent, so the above records
|
||||
// should no longer exist in SQL after this job is run
|
||||
await sql.EnqueueJob(new Job {Payload = new GetNexusUpdatesJob()});
|
||||
await RunAllJobs();
|
||||
|
||||
foreach (var record in oldRecords)
|
||||
{
|
||||
Assert.Null(await sql.GetModFiles(record.Game, record.ModId));
|
||||
Assert.Null(await sql.GetNexusModInfoString(record.Game, record.ModId));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -12,13 +12,13 @@ namespace Wabbajack.Lib.NexusApi
|
||||
public class NexusUpdatesFeeds
|
||||
{
|
||||
|
||||
public static async Task<IEnumerable<UpdateRecord>> GetUpdates()
|
||||
public static async Task<List<UpdateRecord>> GetUpdates()
|
||||
{
|
||||
var updated = GetFeed(new Uri("https://www.nexusmods.com/rss/updatedtoday"));
|
||||
var newToday = GetFeed(new Uri("https://www.nexusmods.com/rss/newtoday"));
|
||||
|
||||
var sorted = (await updated).Concat(await newToday).OrderByDescending(f => f.TimeStamp);
|
||||
var deduped = sorted.GroupBy(g => (g.Game, g.ModId)).Select(g => g.First());
|
||||
var deduped = sorted.GroupBy(g => (g.Game, g.ModId)).Select(g => g.First()).ToList();
|
||||
return deduped;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user