+ 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/v1/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
+