commit: 648e94b369c4a356feda22c0f8ee8a01f7d798f8
parent 7388c4b5ca803ea29547619badb9a22c56643209
Author: Mark Felder <feld@feld.me>
Date: Tue, 13 Aug 2024 15:28:28 -0400
Fix the uploads migration mix task test which leaked a change to the configured Uploader
Diffstat:
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/test/mix/tasks/pleroma/uploads_test.exs b/test/mix/tasks/pleroma/uploads_test.exs
@@ -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