From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Date: Tue, 25 Apr 2023 09:30:11 +0000 (+1200)
Subject: Add error log test (#15768)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=d1cf2779195abeef28bb30ea69eea5fa76ff4473;p=space-station-14.git
Add error log test (#15768)
---
diff --git a/Content.IntegrationTests/Tests/LogErrorTest.cs b/Content.IntegrationTests/Tests/LogErrorTest.cs
new file mode 100644
index 0000000000..17ae6e5f97
--- /dev/null
+++ b/Content.IntegrationTests/Tests/LogErrorTest.cs
@@ -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
+{
+ ///
+ /// This test ensures that error logs cause tests to fail.
+ ///
+ [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();
+
+ // 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(() => Logger.Error("test")));
+ await client.WaitPost(() => Assert.Throws(() => Logger.Error("test")));
+ }
+}