Use regex in formatter test because order of attributes can vary (#705)

Fix test for formatter where the attributes are changing order 
for some reason to not have random test failures.
Used regex to catch both cases.
This commit is contained in:
pascal-fischer 2023-02-28 09:25:44 +01:00 committed by GitHub
parent f984b8a091
commit 9a88ed3cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,8 +20,7 @@ func TestLogMessageFormat(t *testing.T) {
formatter := NewTextFormatter()
result, _ := formatter.Format(someEntry)
expectedString := "2021-02-21T01:10:30Z WARN [att1: 1, att2: 2] some/fancy/path.go:46: Some Message\n"
parsedString := string(result)
assert.Equal(t, expectedString, parsedString, "The log messages don't match.")
expectedString := "^2021-02-21T01:10:30Z WARN \\[(att1: 1, att2: 2|att2: 2, att1: 1)\\] some/fancy/path.go:46: Some Message\\s+$"
assert.Regexp(t, expectedString, parsedString)
}