Fix the uploads migration mix task test which leaked a change to the configured Uploader

This commit is contained in:
Mark Felder 2024-08-13 15:28:28 -04:00
parent 7388c4b5ca
commit 648e94b369

View file

@ -3,12 +3,14 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.UploadsTest do
alias Pleroma.Config
alias Pleroma.Upload
use Pleroma.DataCase
use Pleroma.DataCase, async: false
import Mock
setup_all do
prep_uploads()
Mix.shell(Mix.Shell.Process)
on_exit(fn ->
@ -18,6 +20,8 @@ defmodule Mix.Tasks.Pleroma.UploadsTest do
:ok
end
setup do: clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
describe "running migrate_local" do
test "uploads migrated" do
with_mock Upload,
@ -53,4 +57,15 @@ defmodule Mix.Tasks.Pleroma.UploadsTest do
end
end
end
defp prep_uploads() do
upload_dir = Config.get([Pleroma.Uploaders.Local, :uploads])
if not File.exists?(upload_dir) || File.ls!(upload_dir) == [] do
File.mkdir_p(upload_dir)
Path.join([upload_dir, "file.txt"])
|> File.touch()
end
end
end