From 04e8f866d6500ea7cee91b2ac97ec7e101318d32 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 2 Nov 2018 12:56:08 -0400 Subject: [PATCH] Improve usage of Assert.Inconclusive --- .../IO/TestSymlinkFactory.cs | 4 ++-- .../Tgstation.Server.Tests/AdministrationTest.cs | 15 +++++++++++++-- tests/Tgstation.Server.Tests/TestingServer.cs | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/Tgstation.Server.Host.Tests/IO/TestSymlinkFactory.cs b/tests/Tgstation.Server.Host.Tests/IO/TestSymlinkFactory.cs index 668bf7dd90..db3954cdf1 100644 --- a/tests/Tgstation.Server.Host.Tests/IO/TestSymlinkFactory.cs +++ b/tests/Tgstation.Server.Host.Tests/IO/TestSymlinkFactory.cs @@ -34,7 +34,7 @@ namespace Tgstation.Server.Host.IO.Tests public async Task TestFileWorks() { if (!HasPermissionToMakeSymlinks()) - Assert.Inconclusive(); + Assert.Inconclusive("Current user does not have permission to create symlinks!"); const string Text = "Hello world"; string f2 = null; var f1 = Path.GetTempFileName(); @@ -63,7 +63,7 @@ namespace Tgstation.Server.Host.IO.Tests public async Task TestDirectoryWorks() { if (!HasPermissionToMakeSymlinks()) - Assert.Inconclusive(); + Assert.Inconclusive("Current user does not have permission to create symlinks!"); const string FileName = "TestFile.txt"; const string Text = "Hello world"; string f2 = null; diff --git a/tests/Tgstation.Server.Tests/AdministrationTest.cs b/tests/Tgstation.Server.Tests/AdministrationTest.cs index 9bad0c0168..1e0583424e 100644 --- a/tests/Tgstation.Server.Tests/AdministrationTest.cs +++ b/tests/Tgstation.Server.Tests/AdministrationTest.cs @@ -3,6 +3,7 @@ using System; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using Tgstation.Server.Api.Models; using Tgstation.Server.Client; namespace Tgstation.Server.Tests @@ -23,10 +24,20 @@ namespace Tgstation.Server.Tests async Task TestRead(CancellationToken cancellationToken) { - var model = await client.Read(cancellationToken).ConfigureAwait(false); + Administration model; + try + { + model = await client.Read(cancellationToken).ConfigureAwait(false); + } + catch (RateLimitException) + { + Assert.Inconclusive("GitHub rate limit hit while testing administration endpoint. Set environment variable TGS4_TEST_GITHUB_TOKEN to fix this!"); + return; //c# needs the equivalent of [noreturn] + } Assert.AreEqual(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), model.WindowsHost); - //uhh not much else to do + //we've released a few 4.x versions now, check the release checker is at least somewhat functional + Assert.AreEqual(4, model.LatestVersion.Major); } } } diff --git a/tests/Tgstation.Server.Tests/TestingServer.cs b/tests/Tgstation.Server.Tests/TestingServer.cs index a76ff15d76..f75fbbea6e 100644 --- a/tests/Tgstation.Server.Tests/TestingServer.cs +++ b/tests/Tgstation.Server.Tests/TestingServer.cs @@ -33,10 +33,10 @@ namespace Tgstation.Server.Tests var gitHubAccessToken = Environment.GetEnvironmentVariable("TGS4_TEST_GITHUB_TOKEN"); if (String.IsNullOrEmpty(databaseType)) - Assert.Fail("No database type configured in env var TGS4_TEST_DATABASE_TYPE!"); + Assert.Inconclusive("No database type configured in env var TGS4_TEST_DATABASE_TYPE!"); if (String.IsNullOrEmpty(connectionString)) - Assert.Fail("No connection string configured in env var TGS4_TEST_CONNECTION_STRING!"); + Assert.Inconclusive("No connection string configured in env var TGS4_TEST_CONNECTION_STRING!"); if (String.IsNullOrEmpty(gitHubAccessToken)) Console.WriteLine("WARNING: No GitHub access token configured, test may fail due to rate limits!");