FrontendController: Return error on installation error.

This commit is contained in:
lain 2020-11-17 16:43:07 +01:00
commit bb9650f3c2
4 changed files with 26 additions and 4 deletions

View file

@ -118,5 +118,24 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"]))
end
test "failing returns an error", %{conn: conn} do
Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/madeup.zip"} ->
%Tesla.Env{status: 404, body: ""}
end)
result =
conn
|> put_req_header("content-type", "application/json")
|> post("/api/pleroma/admin/frontends/install", %{
name: "unknown",
ref: "baka",
build_url: "http://gensokyo.2hu/madeup.zip",
build_dir: ""
})
|> json_response_and_validate_schema(400)
assert result == %{"error" => "Could not download or unzip the frontend"}
end
end
end