2
0
mirror of synced 2025-01-29 01:36:16 +00:00
cs-codex-dist-tests/Tests/DistTestCore/DownloadedLogExtensions.cs

28 lines
875 B
C#
Raw Normal View History

using KubernetesWorkflow;
2023-09-12 15:43:30 +02:00
using NUnit.Framework;
namespace DistTestCore
{
public static class DownloadedLogExtensions
{
public static void AssertLogContains(this IDownloadedLog log, string expectedString)
{
2024-03-20 11:11:59 +01:00
Assert.That(log.GetLinesContaining(expectedString).Any(), $"Did not find '{expectedString}' in log.");
2023-09-12 15:43:30 +02:00
}
2023-12-15 09:32:03 +01:00
public static void AssertLogDoesNotContain(this IDownloadedLog log, params string[] unexpectedStrings)
{
2023-12-15 09:32:03 +01:00
var errors = new List<string>();
foreach (var str in unexpectedStrings)
{
2024-03-20 11:11:59 +01:00
var lines = log.GetLinesContaining(str);
foreach (var line in lines)
2023-12-15 09:32:03 +01:00
{
2024-03-20 11:11:59 +01:00
errors.Add($"Found '{str}' in line '{line}'.");
2023-12-15 09:32:03 +01:00
}
}
CollectionAssert.IsEmpty(errors);
}
2023-09-12 15:43:30 +02:00
}
}