Files
tbd-station-14/Content.IntegrationTests/Tests/LogErrorTest.cs
2023-04-25 19:30:11 +10:00

34 lines
1.1 KiB
C#

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")));
}
}