From d1cf2779195abeef28bb30ea69eea5fa76ff4473 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Tue, 25 Apr 2023 21:30:11 +1200 Subject: [PATCH] Add error log test (#15768) --- .../Tests/LogErrorTest.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Content.IntegrationTests/Tests/LogErrorTest.cs 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"))); + } +} -- 2.51.2