forked from AkkomaGang/akkoma
added test
This commit is contained in:
parent
e1d25bad0c
commit
e4b202d905
2 changed files with 28 additions and 1 deletions
|
@ -27,7 +27,8 @@ def create_operation do
|
||||||
422 => Operation.response("Unprocessable Entity", "application/json", ApiError),
|
422 => Operation.response("Unprocessable Entity", "application/json", ApiError),
|
||||||
404 => Operation.response("Not Found", "application/json", ApiError),
|
404 => Operation.response("Not Found", "application/json", ApiError),
|
||||||
400 => Operation.response("Bad Request", "application/json", ApiError),
|
400 => Operation.response("Bad Request", "application/json", ApiError),
|
||||||
409 => Operation.response("Conflict", "application/json", ApiError)
|
409 => Operation.response("Conflict", "application/json", ApiError),
|
||||||
|
500 => Operation.response("Error", "application/json", ApiError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
|
defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
|
import Mock
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
@ -200,6 +201,31 @@ test "add file with not loaded pack", %{admin_conn: admin_conn} do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "returns an error on add file when file system is not writable", %{
|
||||||
|
admin_conn: admin_conn
|
||||||
|
} do
|
||||||
|
pack_file = Path.join([@emoji_path, "not_loaded", "pack.json"])
|
||||||
|
|
||||||
|
with_mocks([
|
||||||
|
{File, [:passthrough], [stat: fn ^pack_file -> {:error, :eacces} end]}
|
||||||
|
]) do
|
||||||
|
assert admin_conn
|
||||||
|
|> put_req_header("content-type", "multipart/form-data")
|
||||||
|
|> post("/api/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||||
|
shortcode: "blank3",
|
||||||
|
filename: "dir/blank.png",
|
||||||
|
file: %Plug.Upload{
|
||||||
|
filename: "blank.png",
|
||||||
|
path: "#{@emoji_path}/test_pack/blank.png"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|> json_response_and_validate_schema(500) == %{
|
||||||
|
"error" =>
|
||||||
|
"Unexpected error occurred while adding file to pack. (POSIX error: Permission denied)"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test "remove file with not loaded pack", %{admin_conn: admin_conn} do
|
test "remove file with not loaded pack", %{admin_conn: admin_conn} do
|
||||||
assert admin_conn
|
assert admin_conn
|
||||||
|> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=blank3")
|
|> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=blank3")
|
||||||
|
|
Loading…
Reference in a new issue