From e706f4cd7e4bc9ebb2e82750cbf837fed79431d6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 14 Oct 2023 00:54:22 -0400 Subject: [PATCH] Fix up all tests except the two main Live ones --- .../Models/Response/ByondResponse.cs | 12 +++++++++++- .../Rights/TestRights.cs | 2 +- .../Engine/TestPosixByondInstaller.cs | 2 +- .../Live/DummyGitHubService.cs | 10 ++++++---- .../Live/Instance/ByondTest.cs | 18 ++++++++++++++---- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/Response/ByondResponse.cs b/src/Tgstation.Server.Api/Models/Response/ByondResponse.cs index 92d524728d..68703f4892 100644 --- a/src/Tgstation.Server.Api/Models/Response/ByondResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ByondResponse.cs @@ -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) { } + + /// + /// Initializes a new instance of the class. + /// + [Obsolete("JSON constructor", true)] + public ByondResponse() + { + } } } diff --git a/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs b/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs index e773f4da94..7589120c61 100644 --- a/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs +++ b/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs @@ -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(); Assert.AreEqual(allByondRights, automaticByondRights); diff --git a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestPosixByondInstaller.cs b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestPosixByondInstaller.cs index f98cb4dc1a..c7f117fb7a 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestPosixByondInstaller.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestPosixByondInstaller.cs @@ -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())); diff --git a/tests/Tgstation.Server.Tests/Live/DummyGitHubService.cs b/tests/Tgstation.Server.Tests/Live/DummyGitHubService.cs index 1b2e711ba6..ad7470d96f 100644 --- a/tests/Tgstation.Server.Tests/Live/DummyGitHubService.cs +++ b/tests/Tgstation.Server.Tests/Live/DummyGitHubService.cs @@ -28,6 +28,8 @@ namespace Tgstation.Server.Tests.Live readonly ICryptographySuite cryptographySuite; readonly ILogger logger; + public static IGitHubClient RealTestClient; + public static async Task InitializeAndInject(CancellationToken cancellationToken) { var mockOptions = new Mock>(); @@ -37,12 +39,12 @@ namespace Tgstation.Server.Tests.Live }); var gitHubClientFactory = new GitHubClientFactory(new AssemblyInformationProvider(), Mock.Of>(), 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); diff --git a/tests/Tgstation.Server.Tests/Live/Instance/ByondTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/ByondTest.cs index 0aa49b4a53..505a480f59 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/ByondTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/ByondTest.cs @@ -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() { - { "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);