mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26:57 +00:00
Feat/error logs (#16)
* 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
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
defmodule PlantIdDiscordBotTest.FileServer.MimeTypes do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias PlantIdDiscordBot.FileServer.MimeTypes
|
||||
doctest MimeTypes
|
||||
|
||||
describe "detect_mime_type/1" do
|
||||
test "detects webp" do
|
||||
bin = <<0x52, 0x49, 0x46, 0x46, 0x00>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:ok, "image/webp"}
|
||||
end
|
||||
|
||||
test "detects jpeg" do
|
||||
bin = <<0xFF, 0xD8, 0xFF, 0x00>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:ok, "image/jpeg"}
|
||||
end
|
||||
|
||||
test "detects png" do
|
||||
bin = <<0x89, 0x50, 0x4E, 0x47, 0x00>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:ok, "image/png"}
|
||||
end
|
||||
|
||||
test "detects gif" do
|
||||
bin = <<0x47, 0x49, 0x46, 0x38, 0x00>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:ok, "image/gif"}
|
||||
end
|
||||
|
||||
test "detects bmp" do
|
||||
bin = <<0x42, 0x4D, 0x00>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:ok, "image/bmp"}
|
||||
end
|
||||
|
||||
test "detects tiff" do
|
||||
bin = <<0x49, 0x49, 0x2A, 0x00, 0x00>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:ok, "image/tiff"}
|
||||
end
|
||||
|
||||
test "returns error for unsupported type" do
|
||||
bin = <<0x00, 0x11, 0x22, 0x33>>
|
||||
assert MimeTypes.detect_mime_type(bin) == {:error, "Unsupported file type"}
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user