mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-22 20:16:57 +00:00
02372f2076
* added list of tasks to achieve * update deps * update elixir version in CI/CD pipeline * update todo with branch push checks * underscores separation of large numbers * update elixir version and deps * add basic module docs * remove IO.inspect call * check if list is empty rather than traversing list for length * revert empty list code * duration tests * add mime type tests * use logger instread of inspect, remove todos * replace list length check with Enum.empty * replace list length check with !Enum.empty? * numbers readability fix by using underscores on large numbers * iucn parser replaced case with multiclause function and added test * replace map and join with map_join * fix multiple spec issues where map() must be inside a list
22 lines
661 B
Elixir
22 lines
661 B
Elixir
defmodule PlantIdDiscordBot.ErrorHandlingTest do
|
|
use ExUnit.Case
|
|
import ExUnit.CaptureLog
|
|
|
|
@guild Application.compile_env(:plantid_discord_bot, :guild)
|
|
|
|
test "do_identification/1 returns invokes logger on error" do
|
|
message = PlantNetFixtures.Message.message()
|
|
|
|
log =
|
|
capture_log(fn ->
|
|
PlantIdDiscordBot.Cog.PlantNetMessage.do_identification(message)
|
|
|
|
assert_received {:create_message, 123_456,
|
|
content: "An error has occured. Please try again later."}
|
|
end)
|
|
|
|
assert log =~ "guild_id=#{message.guild_id}"
|
|
assert log =~ "guild_name=#{@guild.get_guild_name!(message.guild_id)}"
|
|
end
|
|
end
|