From cc066b25cb10e6b7f274253babd781838ee0b00c Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:44:53 -0300 Subject: [PATCH] test: Rollbar.Item.from_message --- lib/tower_rollbar/rollbar/item.ex | 2 +- test/tower_rollbar/rollbar/item_test.exs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/tower_rollbar/rollbar/item.ex b/lib/tower_rollbar/rollbar/item.ex index 2b746fd..7a56584 100644 --- a/lib/tower_rollbar/rollbar/item.ex +++ b/lib/tower_rollbar/rollbar/item.ex @@ -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 diff --git a/test/tower_rollbar/rollbar/item_test.exs b/test/tower_rollbar/rollbar/item_test.exs index 2999c37..101ca2b 100644 --- a/test/tower_rollbar/rollbar/item_test.exs +++ b/test/tower_rollbar/rollbar/item_test.exs @@ -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