mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26:57 +00:00
basic error handling test
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
defmodule PlantIdDiscordBot.ErrorHandlingTest do
|
||||
use ExUnit.Case
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
test "do_identification/1 returns nil when an error occurs" do
|
||||
@guild Application.compile_env(:plantid_discord_bot, :guild)
|
||||
|
||||
test "do_identification/1 returns invokes logger on error" do
|
||||
message = PlantNetFixtures.Message.message()
|
||||
PlantIdDiscordBot.Cog.PlantNetMessage.do_identification(message)
|
||||
|
||||
log = capture_log(fn ->
|
||||
PlantIdDiscordBot.Cog.PlantNetMessage.do_identification(message)
|
||||
|
||||
assert_received {:create_message, 123456, 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
|
||||
|
||||
Reference in New Issue
Block a user