mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-17 19:12:52 +01:00
Fix up all tests except the two main Live ones
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using System;
|
||||
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
|
||||
namespace Tgstation.Server.Api.Models.Response
|
||||
{
|
||||
@@ -15,5 +17,13 @@ namespace Tgstation.Server.Api.Models.Response
|
||||
: base(byondVersion)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ByondResponse"/> class.
|
||||
/// </summary>
|
||||
[Obsolete("JSON constructor", true)]
|
||||
public ByondResponse()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Tgstation.Server.Api.Rights.Tests
|
||||
[TestMethod]
|
||||
public void TestAllRightsWorks()
|
||||
{
|
||||
var allByondRights = ByondRights.CancelInstall | ByondRights.InstallOfficialOrChangeActiveByondVersion | ByondRights.ListInstalled | ByondRights.ReadActive | ByondRights.InstallCustomByondVersion | ByondRights.DeleteInstall;
|
||||
var allByondRights = ByondRights.CancelInstall | ByondRights.InstallOfficialOrChangeActiveByondVersion | ByondRights.ListInstalled | ByondRights.ReadActive | ByondRights.InstallCustomByondVersion | ByondRights.DeleteInstall | ByondRights.InstallCustomOpenDreamVersion | ByondRights.InstallOfficialOrChangeActiveOpenDreamVersion;
|
||||
var automaticByondRights = RightsHelper.AllRights<ByondRights>();
|
||||
|
||||
Assert.AreEqual(allByondRights, automaticByondRights);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Tgstation.Server.Host.Components.Engine.Tests
|
||||
var result = ExtractMemoryStreamFromInstallationData(await installer.DownloadVersion(new ByondVersion
|
||||
{
|
||||
Engine = EngineType.Byond,
|
||||
Version = new Version(123, 252345),
|
||||
Version = new Version(511, 1385),
|
||||
}, null, default));
|
||||
|
||||
Assert.IsTrue(ourArray.SequenceEqual(result.ToArray()));
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Tgstation.Server.Tests.Live
|
||||
readonly ICryptographySuite cryptographySuite;
|
||||
readonly ILogger<DummyGitHubService> logger;
|
||||
|
||||
public static IGitHubClient RealTestClient;
|
||||
|
||||
public static async Task InitializeAndInject(CancellationToken cancellationToken)
|
||||
{
|
||||
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
|
||||
@@ -37,12 +39,12 @@ namespace Tgstation.Server.Tests.Live
|
||||
});
|
||||
|
||||
var gitHubClientFactory = new GitHubClientFactory(new AssemblyInformationProvider(), Mock.Of<ILogger<GitHubClientFactory>>(), mockOptions.Object);
|
||||
var gitHubClient = gitHubClientFactory.CreateClient();
|
||||
RealTestClient = gitHubClientFactory.CreateClient();
|
||||
|
||||
Release targetRelease;
|
||||
do
|
||||
{
|
||||
var releases = await gitHubClient
|
||||
var releases = await RealTestClient
|
||||
.Repository
|
||||
.Release
|
||||
.GetAll("tgstation", "tgstation-server")
|
||||
@@ -57,12 +59,12 @@ namespace Tgstation.Server.Tests.Live
|
||||
{ TestLiveServer.TestUpdateVersion, targetRelease }
|
||||
};
|
||||
|
||||
var testCommitTask = gitHubClient
|
||||
var testCommitTask = RealTestClient
|
||||
.Repository
|
||||
.Commit
|
||||
.Get("Cyberboss", "common_core", "4b4926dfaf6295f19f8ae7abf03cb357dbb05b29")
|
||||
.WaitAsync(cancellationToken);
|
||||
testPr = await gitHubClient
|
||||
testPr = await RealTestClient
|
||||
.PullRequest
|
||||
.Get("Cyberboss", "common_core", 2)
|
||||
.WaitAsync(cancellationToken);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
this.byondClient = byondClient ?? throw new ArgumentNullException(nameof(byondClient));
|
||||
this.fileDownloader = fileDownloader ?? throw new ArgumentNullException(nameof(fileDownloader));
|
||||
this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata));
|
||||
this.testEngine = engineType;
|
||||
testEngine = engineType;
|
||||
}
|
||||
|
||||
public Task Run(CancellationToken cancellationToken, out Task firstInstall)
|
||||
@@ -82,7 +82,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
// linux map also needs updating in CI
|
||||
: new Dictionary<string, string>()
|
||||
{
|
||||
{ "515.1612", "515.1611" }
|
||||
{ "515.1612", "515.1611" }
|
||||
};
|
||||
|
||||
if (missingVersionMap.TryGetValue(targetVersion, out var remappedVersion))
|
||||
@@ -90,9 +90,19 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
|
||||
Assert.IsTrue(ByondVersion.TryParse(targetVersion, out byondVersion), $"Bad version: {targetVersion}");
|
||||
}
|
||||
else if (engineType == EngineType.OpenDream)
|
||||
{
|
||||
var masterBranch = await DummyGitHubService.RealTestClient.Repository.Branch.Get("OpenDreamProject", "OpenDream", "master");
|
||||
|
||||
byondVersion = new ByondVersion
|
||||
{
|
||||
Engine = EngineType.OpenDream,
|
||||
SourceCommittish = masterBranch.Commit.Sha,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail($"Edge version retrieval for {engineType} not implemented!");
|
||||
Assert.Fail($"Unimplemented edge retrieval for engine type: {engineType}");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -101,7 +111,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
|
||||
async Task RunPartOne(CancellationToken cancellationToken)
|
||||
{
|
||||
testVersion = await GetEdgeVersion(EngineType.Byond, fileDownloader, cancellationToken);
|
||||
testVersion = await GetEdgeVersion(testEngine, fileDownloader, cancellationToken);
|
||||
await TestNoVersion(cancellationToken);
|
||||
await TestInstallNullVersion(cancellationToken);
|
||||
await TestInstallStable(cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user