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 Mix.Tasks.Pleroma.UploadsTest do
12 Mix.shell(Mix.Shell.Process)
15 Mix.shell(Mix.Shell.IO)
21 describe "running migrate_local" do
22 test "uploads migrated" do
24 store: fn %Upload{name: _file, path: _path}, _opts -> {:ok, %{}} end do
25 Mix.Tasks.Pleroma.Uploads.run(["migrate_local", "S3"])
27 assert_received {:mix_shell, :info, [message]}
28 assert message =~ "Migrating files from local"
30 assert_received {:mix_shell, :info, [message]}
32 assert %{"total_count" => total_count} =
33 Regex.named_captures(~r"^Found (?<total_count>\d+) uploads$", message)
35 assert_received {:mix_shell, :info, [message]}
37 # @logevery in Mix.Tasks.Pleroma.Uploads
39 min(50, String.to_integer(total_count))
42 assert %{"count" => ^count, "total_count" => ^total_count} =
44 ~r"^Uploaded (?<count>\d+)/(?<total_count>\d+) files$",
50 test "nonexistent uploader" do
51 assert_raise RuntimeError, ~r/The uploader .* is not an existing/, fn ->
52 Mix.Tasks.Pleroma.Uploads.run(["migrate_local", "nonexistent"])