1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.UploaderControllerTest do
6 use Pleroma.Web.ConnCase, async: true
7 alias Pleroma.Uploaders.Uploader
9 describe "callback/2" do
10 test "it returns 400 response when process callback isn't alive", %{conn: conn} do
13 |> post(uploader_path(conn, :callback, "test-path"))
15 assert res.status == 400
16 assert res.resp_body == "{\"error\":\"bad request\"}"
19 test "it returns success result", %{conn: conn} do
23 {Uploader, pid, conn, _params} ->
27 |> Phoenix.Controller.json(%{upload_path: "test-path"})
29 send(pid, {Uploader, conn})
33 :global.register_name({Uploader, "test-path"}, task.pid)
37 |> post(uploader_path(conn, :callback, "test-path"))
40 assert res == %{"upload_path" => "test-path"}