]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add error log test (#15768)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Tue, 25 Apr 2023 09:30:11 +0000 (21:30 +1200)
committerGitHub <noreply@github.com>
Tue, 25 Apr 2023 09:30:11 +0000 (19:30 +1000)
Content.IntegrationTests/Tests/LogErrorTest.cs [new file with mode: 0644]

diff --git a/Content.IntegrationTests/Tests/LogErrorTest.cs b/Content.IntegrationTests/Tests/LogErrorTest.cs
new file mode 100644 (file)
index 0000000..17ae6e5
--- /dev/null
@@ -0,0 +1,33 @@
+using System.Threading.Tasks;
+using NUnit.Framework;
+using Robust.Shared.Configuration;
+using Robust.Shared.Log;
+using Robust.UnitTesting;
+
+namespace Content.IntegrationTests.Tests;
+
+public sealed class LogErrorTest
+{
+    /// <summary>
+    ///     This test ensures that error logs cause tests to fail.
+    /// </summary>
+    [Test]
+    public async Task TestLogErrorCausesTestFailure()
+    {
+        await using var pairTracker = await PoolManager.GetServerClient();
+        var server = pairTracker.Pair.Server;
+        var client = pairTracker.Pair.Client;
+
+        var cfg = server.ResolveDependency<IConfigurationManager>();
+
+        // Default cvar is properly configured
+        Assert.That(cfg.GetCVar(RTCVars.FailureLogLevel), Is.EqualTo(LogLevel.Error));
+
+        // Warnings don't cause tests to fail.
+        await server.WaitPost(() => Logger.Warning("test"));
+
+        // But errors do
+        await server.WaitPost(() => Assert.Throws<AssertionException>(() => Logger.Error("test")));
+        await client.WaitPost(() => Assert.Throws<AssertionException>(() => Logger.Error("test")));
+    }
+}