Skip to content

Commit

Permalink
Update unit tests with more failure scenario's
Browse files Browse the repository at this point in the history
  • Loading branch information
APErebus committed Dec 2, 2024
1 parent 001d5ef commit a1e5b8e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,33 @@ public void NotCorrectlyPipeDelimited(string line)
result.Error.Should().Contain("delimited").And.Contain(line);
}

[TestCase("1 |e|b|c|d", Reason = "Not a date")]
[TestCase("1 |b|c|d", Reason = "Not a date")]
public void FirstPartIsNotALineDate(string line)
{
var result = PodLogLineParser.ParseLine(line, encryptionProvider).Should().BeOfType<InvalidPodLogLineParseResult>().Subject;
result.Error.Should().Contain("log timestamp").And.Contain(line);
}

[TestCase("2024-04-03T06:03:10.501025551Z |e|b|c|d", Reason = "Not a line number")]
[TestCase("2024-04-03T06:03:10.501025551Z |p|b|c|d", Reason = "Not a line number")]
[TestCase("2024-04-03T06:03:10.501025551Z |b|c|d", Reason = "Not a line number")]
public void SecondPartIsNotALineNumber(string line)
[TestCase("2024-04-03T06:03:10.501025551Z |p|1|c|d", Reason = "Not a line number")]
public void ThirdPartIsNotALineNumber(string line)
{
var result = PodLogLineParser.ParseLine(line, encryptionProvider).Should().BeOfType<InvalidPodLogLineParseResult>().Subject;
result.Error.Should().Contain("line number").And.Contain(line);
}

[TestCase("2024-04-03T06:03:10.501025551Z |e|1|c|d", Reason = "Not a valid source")]
[TestCase("2024-04-03T06:03:10.501025551Z |1|c|d", Reason = "Not a valid source")]
public void ThirdPartIsNotAValidSource(string line)
public void FourthPartIsNotAValidSource(string line)
{
var result = PodLogLineParser.ParseLine(line, encryptionProvider).Should().BeOfType<InvalidPodLogLineParseResult>().Subject;
result.Error.Should().Contain("log level").And.Contain(line);
}

[TestCase("2024-04-03T06:03:10.501025551Z |e|123|stdout|This is the message", true)]
[TestCase("2024-04-03T06:03:10.501025551Z |p|123|stdout|This is the message", false)]
//This is the previous log message format where we didn't have the encryption control section
[TestCase("2024-04-03T06:03:10.501025551Z |123|stdout|This is the message", false)]
public void SimpleMessage(string line, bool isLogMessageEncrypted)
Expand Down

0 comments on commit a1e5b8e

Please sign in to comment.