44 lines
1.4 KiB
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);
}
public static void AssertLogDoesNotContainLinesStartingWith(this IDownloadedLog log, params string[] unexpectedStrings)
{
var errors = new List<string>();
log.IterateLines(line =>
{
foreach (var str in unexpectedStrings)
{
if (line.StartsWith(str))
{
errors.Add($"Found '{str}' at start of line '{line}'.");
}
}
});
CollectionAssert.IsEmpty(errors);
}
2023-09-12 15:43:30 +02:00
}
}