image saving with basic error handling

This commit is contained in:
Owen
2024-12-16 16:25:38 +01:00
parent 5a5700fab7
commit c04b7f2d22
13 changed files with 116 additions and 9 deletions
+13
View File
@@ -0,0 +1,13 @@
defmodule PlantIdDiscordBotTest.FileServer.File do
use ExUnit.Case
doctest PlantIdDiscordBot.FileServer.File
@image_path Application.compile_env(:plantid_discord_bot, :image_path)
test "generate_unique_filename" do
file_path = PlantIdDiscordBot.FileServer.File.generate_unique_filename("jpg")
file_name = Path.basename(file_path)
assert Regex.match?(~r/^[0-9A-F]{16}\.jpg$/, file_name)
assert file_path == Path.join(@image_path, file_name)
end
end
+1 -1
View File
@@ -7,7 +7,7 @@ defmodule PlantIdDiscordBotTest.PlantNet.Parser do
test "to_map" do
result =
PlantNetFixtures.raw_response()
|> Parser.to_map()
|> Parser.to_map!()
assert result == PlantNetFixtures.parsed_response()
end