Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDryga committed May 14, 2024
1 parent e0c79b9 commit 46625c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions test/logger_json/formatter/message_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule LoggerJSON.Formatter.MessageTest do
setup do
# Define mock formatters
binary_fmt = fn data -> "Binary: #{data}" end
structured_fmt = fn data -> "Structured: #{inspect(data)}" end
structured_fmt = fn data -> "Structured: #{data |> Enum.sort() |> inspect()}" end
crash_fmt = fn message, reason -> "Crash: #{message} - #{reason}" end

{:ok, formatters: %{binary: binary_fmt, structured: structured_fmt, crash: crash_fmt}}
Expand All @@ -29,7 +29,7 @@ defmodule LoggerJSON.Formatter.MessageTest do
meta = %{}

assert format_message(message, meta, %{structured: formatters.structured}) ==
"Structured: %{id: 1, content: \"Report data\"}"
~s|Structured: [content: "Report data", id: 1]|
end

test "formats reports with custom callbacks altering the data", %{formatters: formatters} do
Expand All @@ -51,7 +51,7 @@ defmodule LoggerJSON.Formatter.MessageTest do
test "formats report with default behavior", %{formatters: formatters} do
message = {:report, %{id: 2, content: "Another report"}}
meta = %{report_cb: &:logger.format_otp_report/1}
assert format_message(message, meta, formatters) == "Structured: %{id: 2, content: \"Another report\"}"
assert format_message(message, meta, formatters) == ~s|Structured: [content: "Another report", id: 2]|
end

test "formats general message using Logger.Utils.scan_inspect", %{formatters: formatters} do
Expand Down
8 changes: 4 additions & 4 deletions test/logger_json/formatters/datadog_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ defmodule LoggerJSON.Formatters.DatadogTest do
assert %{
"error" => %{"message" => "error here"},
"logger" => %{
"file_name" => "/Users/andrew/Projects/os/logger_json/test/logger_json/formatters/datadog_test.exs",
"file_name" => _file,
"line" => _line,
"method_name" => "Elixir.LoggerJSON.Formatters.DatadogTest." <> _,
"thread_name" => _pid
Expand All @@ -366,7 +366,7 @@ defmodule LoggerJSON.Formatters.DatadogTest do
assert %{
"error" => %{"message" => "error here"},
"logger" => %{
"file_name" => "/Users/andrew/Projects/os/logger_json/test/logger_json/formatters/datadog_test.exs",
"file_name" => _file,
"line" => _line,
"method_name" => "Elixir.LoggerJSON.Formatters.DatadogTest." <> _,
"thread_name" => _pid
Expand All @@ -386,7 +386,7 @@ defmodule LoggerJSON.Formatters.DatadogTest do
assert %{
"error" => %{"message" => "error here"},
"logger" => %{
"file_name" => "/Users/andrew/Projects/os/logger_json/test/logger_json/formatters/datadog_test.exs",
"file_name" => _file,
"line" => _line,
"method_name" => "Elixir.LoggerJSON.Formatters.DatadogTest." <> _,
"thread_name" => _pid
Expand All @@ -406,7 +406,7 @@ defmodule LoggerJSON.Formatters.DatadogTest do
assert %{
"error" => %{"message" => "error here"},
"logger" => %{
"file_name" => "/Users/andrew/Projects/os/logger_json/test/logger_json/formatters/datadog_test.exs",
"file_name" => _file,
"line" => _line,
"method_name" => "Elixir.LoggerJSON.Formatters.DatadogTest." <> _,
"thread_name" => _pid
Expand Down

0 comments on commit 46625c4

Please sign in to comment.