From 2de7164ab2e4a2d710a798b89d664b89f24e04c0 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 21 Sep 2022 19:51:39 -0400 Subject: [PATCH] Add a regression test --- .../Instance/RepositoryTest.cs | 2 -- tests/Tgstation.Server.Tests/IntegrationTest.cs | 15 ++++++++++++++- tests/Tgstation.Server.Tests/TestingServer.cs | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs b/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs index d4941e4e80..74ba887424 100644 --- a/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs @@ -214,8 +214,6 @@ namespace Tgstation.Server.Tests.Instance public async Task RunPostTest(CancellationToken cancellationToken) { - - var deleting = await repositoryClient.Delete(cancellationToken); Assert.IsNotNull(deleting.ActiveJob); diff --git a/tests/Tgstation.Server.Tests/IntegrationTest.cs b/tests/Tgstation.Server.Tests/IntegrationTest.cs index 4dc6800f48..b821ca125b 100644 --- a/tests/Tgstation.Server.Tests/IntegrationTest.cs +++ b/tests/Tgstation.Server.Tests/IntegrationTest.cs @@ -199,6 +199,13 @@ namespace Tgstation.Server.Tests new TestingServer(null, false).Dispose(); } + [TestMethod] + public async Task TestCreateServerWithNoArguments() + { + using var server = new TestingServer(null, false); + await server.RunNoArgumentsTest(default); + } + [TestMethod] public async Task TestSwarmSynchronizationAndUpdates() { @@ -796,7 +803,7 @@ namespace Tgstation.Server.Tests } [TestMethod] - public async Task TestServer() + public async Task TestTgs() { var procs = System.Diagnostics.Process.GetProcessesByName("byond"); if (procs.Any()) @@ -815,6 +822,8 @@ namespace Tgstation.Server.Tests var cancellationToken = serverCts.Token; TerminateAllDDs(); + + // main run var serverTask = server.Run(cancellationToken); try @@ -880,6 +889,7 @@ namespace Tgstation.Server.Tests blockingSocket.Bind(new IPEndPoint(IPAddress.Any, server.Url.Port)); try { + // bind test run await server.Run(cancellationToken); Assert.Fail("Expected server task to end with a SocketException"); } @@ -894,6 +904,7 @@ namespace Tgstation.Server.Tests var preStartupTime = DateTimeOffset.UtcNow; + // chat bot start and DD reattach test serverTask = server.Run(cancellationToken); using (var adminClient = await CreateAdminClient(server.Url, cancellationToken)) { @@ -937,6 +948,8 @@ namespace Tgstation.Server.Tests Assert.IsTrue(serverTask.IsCompleted); preStartupTime = DateTimeOffset.UtcNow; + + // chat bot start, dd autostart, and entity delete tests serverTask = server.Run(cancellationToken); using (var adminClient = await CreateAdminClient(server.Url, cancellationToken)) { diff --git a/tests/Tgstation.Server.Tests/TestingServer.cs b/tests/Tgstation.Server.Tests/TestingServer.cs index 878527bb15..3490255754 100644 --- a/tests/Tgstation.Server.Tests/TestingServer.cs +++ b/tests/Tgstation.Server.Tests/TestingServer.cs @@ -1,4 +1,4 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Globalization; @@ -138,6 +138,19 @@ namespace Tgstation.Server.Tests } } + public async Task RunNoArgumentsTest(CancellationToken cancellationToken) + { + Assert.IsNull(Environment.GetEnvironmentVariable("General:SetupWizardMode")); + Environment.SetEnvironmentVariable("General:SetupWizardMode", "Never"); + await Application + .CreateDefaultServerFactory() + .CreateServer( + Array.Empty(), + UpdatePath, + cancellationToken); + Environment.SetEnvironmentVariable("General:SetupWizardMode", null); + } + public async Task Run(CancellationToken cancellationToken) { Console.WriteLine("TEST SERVER START"); @@ -147,7 +160,7 @@ namespace Tgstation.Server.Tests .CreateServer( args, UpdatePath, - default); + cancellationToken); if (firstRun) {