diff --git a/tests/Tgstation.Server.Tests/CachingFileDownloader.cs b/tests/Tgstation.Server.Tests/CachingFileDownloader.cs index 3d5eb95024..1ed2b172b7 100644 --- a/tests/Tgstation.Server.Tests/CachingFileDownloader.cs +++ b/tests/Tgstation.Server.Tests/CachingFileDownloader.cs @@ -78,20 +78,21 @@ namespace Tgstation.Server.Tests public static async ValueTask InitializeByondVersion(ILogger logger, Version version, bool windows, CancellationToken cancellationToken) { - // actions is supposed to cache BYOND for us - if (!TestingUtils.RunningInGitHubActions) - return; - var url = new Uri( - $"https://www.byond.com/download/build/{version.Major}/{version.Major}.{version.Minor}_byond{(!windows ? "_linux" : string.Empty)}.zip"); + $"https://www.byond.com/download/build/{version.Major}/{version.Major}.{version.Minor}_byond{(!windows ? "_linux" : string.Empty)}.zip"); + string path = null; + if (TestingUtils.RunningInGitHubActions) + { + // actions is supposed to cache BYOND for us - var dir = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), - "byond-zips-cache", - windows ? "windows" : "linux"); - var path = Path.Combine( - dir, - $"{version.Major}.{version.Minor}.zip"); + var dir = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "byond-zips-cache", + windows ? "windows" : "linux"); + path = Path.Combine( + dir, + $"{version.Major}.{version.Minor}.zip"); + } await (await CacheFile(logger, url, null, path, cancellationToken)).DisposeAsync(); } diff --git a/tests/Tgstation.Server.Tests/TestVersions.cs b/tests/Tgstation.Server.Tests/TestVersions.cs index c427b04fb2..875282d1f7 100644 --- a/tests/Tgstation.Server.Tests/TestVersions.cs +++ b/tests/Tgstation.Server.Tests/TestVersions.cs @@ -19,16 +19,15 @@ using Newtonsoft.Json.Linq; using Tgstation.Server.Api; using Tgstation.Server.Client; -using Tgstation.Server.Common.Http; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host; using Tgstation.Server.Host.Components.Byond; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; +using System.Net; namespace Tgstation.Server.Tests { @@ -97,14 +96,21 @@ namespace Tgstation.Server.Tests var mockSessionConfigurationOptions = new Mock>(); mockSessionConfigurationOptions.SetupGet(x => x.Value).Returns(new SessionConfiguration()); + using var loggerFactory = LoggerFactory.Create(builder => + { + builder.AddConsole(); + builder.SetMinimumLevel(LogLevel.Trace); + }); + var logger = loggerFactory.CreateLogger(); + // windows only BYOND but can be checked on any system var init1 = CachingFileDownloader.InitializeByondVersion( - null, + logger, WindowsByondInstaller.DDExeVersion, true, CancellationToken.None); await CachingFileDownloader.InitializeByondVersion( - null, + logger, new Version(WindowsByondInstaller.DDExeVersion.Major, WindowsByondInstaller.DDExeVersion.Minor - 1), true, CancellationToken.None); @@ -150,17 +156,26 @@ namespace Tgstation.Server.Tests }); var platformIdentifier = new PlatformIdentifier(); - var init1 = CachingFileDownloader.InitializeByondVersion( - null, - ByondInstallerBase.MapThreadsVersion, - platformIdentifier.IsWindows, - CancellationToken.None); - await CachingFileDownloader.InitializeByondVersion( - null, - new Version(ByondInstallerBase.MapThreadsVersion.Major, ByondInstallerBase.MapThreadsVersion.Minor - 1), - platformIdentifier.IsWindows, - CancellationToken.None); - await init1; + try + { + var logger = loggerFactory.CreateLogger(); + var init1 = CachingFileDownloader.InitializeByondVersion( + logger, + ByondInstallerBase.MapThreadsVersion, + platformIdentifier.IsWindows, + CancellationToken.None); + await CachingFileDownloader.InitializeByondVersion( + logger, + new Version(ByondInstallerBase.MapThreadsVersion.Major, ByondInstallerBase.MapThreadsVersion.Minor - 1), + platformIdentifier.IsWindows, + CancellationToken.None); + await init1; + } + catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound) + { + Assert.Inconclusive("-map-threads version appears to not have been released yet!"); + } + var fileDownloader = new CachingFileDownloader(Mock.Of>()); IByondInstaller byondInstaller = platformIdentifier.IsWindows @@ -216,6 +231,8 @@ namespace Tgstation.Server.Tests { await ioManager.DeleteDirectory(tempPath, default); } + + Assert.Fail("Test succeeded, but remove the 404 workaround!"); } [ClassCleanup]