diff options
author | rinpatch <rinpatch@sdf.org> | 2018-12-18 21:39:36 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2018-12-18 21:39:36 +0300 |
commit | ef318fb8a96ddf276393f4ec81d3242dd7c6a4d4 (patch) | |
tree | a030123a4bbe071613e87c41bee00333727208dc /test/tasks/uploads_test.exs | |
parent | 059dd6f681caf14ee9d288ec14b82132be29ae2c (diff) | |
parent | 443d59baa05165c3b5b7ab14f3eabd6f2eba09f2 (diff) | |
download | pleroma-ef318fb8a96ddf276393f4ec81d3242dd7c6a4d4.tar.gz pleroma-ef318fb8a96ddf276393f4ec81d3242dd7c6a4d4.zip |
Merge branch 'develop' into fix/formatter-ignore-html-chars
Diffstat (limited to 'test/tasks/uploads_test.exs')
-rw-r--r-- | test/tasks/uploads_test.exs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/tasks/uploads_test.exs b/test/tasks/uploads_test.exs new file mode 100644 index 000000000..93035abb6 --- /dev/null +++ b/test/tasks/uploads_test.exs @@ -0,0 +1,52 @@ +defmodule Mix.Tasks.Pleroma.UploadsTest do + alias Pleroma.Upload + use Pleroma.DataCase + + import Mock + + setup_all do + Mix.shell(Mix.Shell.Process) + + on_exit(fn -> + Mix.shell(Mix.Shell.IO) + end) + + :ok + end + + describe "running migrate_local" do + test "uploads migrated" do + with_mock Upload, + store: fn %Upload{name: _file, path: _path}, _opts -> {:ok, %{}} end do + Mix.Tasks.Pleroma.Uploads.run(["migrate_local", "S3"]) + + assert_received {:mix_shell, :info, [message]} + assert message =~ "Migrating files from local" + + assert_received {:mix_shell, :info, [message]} + + assert %{"total_count" => total_count} = + Regex.named_captures(~r"^Found (?<total_count>\d+) uploads$", message) + + assert_received {:mix_shell, :info, [message]} + + # @logevery in Mix.Tasks.Pleroma.Uploads + count = + min(50, String.to_integer(total_count)) + |> to_string() + + assert %{"count" => ^count, "total_count" => ^total_count} = + Regex.named_captures( + ~r"^Uploaded (?<count>\d+)/(?<total_count>\d+) files$", + message + ) + end + end + + test "nonexistent uploader" do + assert_raise RuntimeError, ~r/The uploader .* is not an existing/, fn -> + Mix.Tasks.Pleroma.Uploads.run(["migrate_local", "nonexistent"]) + end + end + end +end |