diff options
author | rinpatch <rinpatch@sdf.org> | 2019-07-20 22:04:47 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-07-20 22:04:47 +0300 |
commit | 196cad46f35a63c18d58cd5d982bc4e1f9b0d7c3 (patch) | |
tree | 51fa0436998541c3bcc1885eaa2188d7dbb7d469 /test/web/uploader_controller_test.exs | |
parent | c3ecaea64dd377b586e3b2a5316e90884ec78fe6 (diff) | |
parent | fe548f322e834c7c81678a460c54c71f1198021c (diff) | |
download | pleroma-196cad46f35a63c18d58cd5d982bc4e1f9b0d7c3.tar.gz |
Resolve merge conflicts
Diffstat (limited to 'test/web/uploader_controller_test.exs')
-rw-r--r-- | test/web/uploader_controller_test.exs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/web/uploader_controller_test.exs b/test/web/uploader_controller_test.exs new file mode 100644 index 000000000..70028df1c --- /dev/null +++ b/test/web/uploader_controller_test.exs @@ -0,0 +1,43 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.UploaderControllerTest do + use Pleroma.Web.ConnCase + alias Pleroma.Uploaders.Uploader + + describe "callback/2" do + test "it returns 400 response when process callback isn't alive", %{conn: conn} do + res = + conn + |> post(uploader_path(conn, :callback, "test-path")) + + assert res.status == 400 + assert res.resp_body == "{\"error\":\"bad request\"}" + end + + test "it returns success result", %{conn: conn} do + task = + Task.async(fn -> + receive do + {Uploader, pid, conn, _params} -> + conn = + conn + |> put_status(:ok) + |> Phoenix.Controller.json(%{upload_path: "test-path"}) + + send(pid, {Uploader, conn}) + end + end) + + :global.register_name({Uploader, "test-path"}, task.pid) + + res = + conn + |> post(uploader_path(conn, :callback, "test-path")) + |> json_response(200) + + assert res == %{"upload_path" => "test-path"} + end + end +end |