akkoma/test/mix/tasks/pleroma/uploads_test.exs
FloatingGhost 98cb255d12 Support elixir1.15
OTP builds to 1.15

Changelog entry

Ensure policies are fully loaded

Fix :warn

use main branch for linkify

Fix warn in tests

Migrations for phoenix 1.17

Revert "Migrations for phoenix 1.17"

This reverts commit 6a3b2f15b7.

Oban upgrade

Add default empty whitelist

mix format

limit test to amd64

OTP 26 tests for 1.15

use OTP_VERSION tag

baka

just 1.15

Massive deps update

Update locale, deps

Mix format

shell????

multiline???

?

max cases 1

use assert_recieve

don't put_env in async tests

don't async conn/fs tests

mix format

FIx some uploader issues

Fix tests
2023-08-03 17:44:09 +01:00

56 lines
1.6 KiB
Elixir

# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.UploadsTest do
alias Pleroma.Upload
use Pleroma.DataCase, async: false
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_receive {:mix_shell, :info, [message]}
assert message =~ "Migrating files from local"
assert_receive {:mix_shell, :info, [message]}
assert %{"total_count" => total_count} =
Regex.named_captures(~r"^Found (?<total_count>\d+) uploads$", message)
assert_receive {: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