Skip to content

Commit

Permalink
test: Rollbar.Item.from_message
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Jun 11, 2024
1 parent e72c89e commit cc066b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tower_rollbar/rollbar/item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule TowerRollbar.Rollbar.Item do
"body" => message
}
}
|> item_from_body(options)
|> item_from_body(Keyword.merge([level: :info], options))
end

defp item_from_body(body, options) when is_map(body) do
Expand Down
19 changes: 19 additions & 0 deletions test/tower_rollbar/rollbar/item_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,23 @@ defmodule TowerRollbar.Rollbar.ItemTest do
}
} = item
end

test "from_message" do
Application.put_env(:tower_rollbar, :environment, "test")

item = Rollbar.Item.from_message("something interesting happened")

assert %{
"data" => %{
"environment" => "test",
"timestamp" => _,
"level" => "info",
"body" => %{
"message" => %{
"body" => "something interesting happened"
}
}
}
} = item
end
end

0 comments on commit cc066b2

Please sign in to comment.