wabbajack/Wabbajack.Test/GitHubTests.cs

51 lines
1.8 KiB
C#
Raw Normal View History

2021-07-19 22:15:27 +00:00
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Documents;
using Octokit;
using Wabbajack.Common;
using Wabbajack.Lib.GitHub;
using Wabbajack.Lib.ModListRegistry;
using Xunit;
namespace Wabbajack.Test
{
public class GitHubTests
{
2021-07-21 04:47:00 +00:00
//[Fact] - Disabled for build server, run locally
2021-07-19 22:15:27 +00:00
public async Task CanLogIntoGithub()
{
var client = await Wabbajack.Lib.GitHub.Client.Get();
var rnd = new Random();
var meta = new DownloadMetadata
{
Hash = Hash.FromLong(rnd.Next()),
NumberOfArchives = rnd.Next(100),
NumberOfInstalledFiles = rnd.Next(1000),
SizeOfInstalledFiles = rnd.Next(1000000),
Size = rnd.Next(10000),
2021-07-20 05:08:12 +00:00
};
var update = new UpdateRequest
{
DownloadMetadata = meta,
DownloadUrl = new Uri($"https://www.google.com/{rnd.Next()}"),
MachineUrl = "ci_test",
Version = new Version(1, rnd.Next(10), rnd.Next(10), rnd.Next(10))
2021-07-19 22:15:27 +00:00
};
2021-07-20 05:08:12 +00:00
await client.UpdateList("ci_tester", update);
2021-07-19 22:15:27 +00:00
var updated = await client.GetData(Client.List.CI);
var lst = updated.Lists.FirstOrDefault(l => l.Links.MachineURL == "ci_test");
var newMeta = lst!.DownloadMetadata!;
Assert.Equal(meta.Hash, newMeta.Hash);
Assert.Equal(meta.Size, newMeta.Size);
2021-07-20 05:08:12 +00:00
Assert.Equal(update.Version, lst.Version);
2021-07-19 22:15:27 +00:00
Assert.Equal(meta.NumberOfArchives, newMeta.NumberOfArchives);
Assert.Equal(meta.NumberOfInstalledFiles, newMeta.NumberOfInstalledFiles);
Assert.Equal(meta.SizeOfInstalledFiles, newMeta.SizeOfInstalledFiles);
}
}
}