forked from AkkomaGang/akkoma
Fix tests
This commit is contained in:
parent
be42ab70dc
commit
75e07ba206
2 changed files with 38 additions and 12 deletions
|
@ -39,7 +39,8 @@ def upload(zip_path) do
|
||||||
path: id <> "/" <> file_name
|
path: id <> "/" <> file_name
|
||||||
}
|
}
|
||||||
|
|
||||||
with :ok <- uploader.put_file(upload), :ok <- File.rm(zip_path) do
|
with {:ok, _} <- Pleroma.Uploaders.Uploader.put_file(uploader, upload),
|
||||||
|
:ok <- File.rm(zip_path) do
|
||||||
{:ok, upload}
|
{:ok, upload}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.ExportTest do
|
defmodule Pleroma.ExportTest do
|
||||||
use Pleroma.DataCase
|
use Pleroma.DataCase
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
import Mock
|
||||||
|
|
||||||
alias Pleroma.Bookmark
|
alias Pleroma.Bookmark
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
|
@ -109,7 +110,15 @@ test "it exports user data" do
|
||||||
File.rm!(path)
|
File.rm!(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it uploads an exported backup archive" do
|
describe "it uploads an exported backup archive" do
|
||||||
|
setup do
|
||||||
|
clear_config(Pleroma.Uploaders.S3,
|
||||||
|
bucket: "test_bucket",
|
||||||
|
public_endpoint: "https://s3.amazonaws.com"
|
||||||
|
)
|
||||||
|
|
||||||
|
clear_config([Pleroma.Upload, :uploader])
|
||||||
|
|
||||||
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})
|
||||||
|
|
||||||
{:ok, status1} = CommonAPI.post(user, %{status: "status1"})
|
{:ok, status1} = CommonAPI.post(user, %{status: "status1"})
|
||||||
|
@ -121,6 +130,22 @@ test "it uploads an exported backup archive" do
|
||||||
Bookmark.create(user.id, status3.id)
|
Bookmark.create(user.id, status3.id)
|
||||||
|
|
||||||
assert {:ok, path} = Pleroma.Export.run(user)
|
assert {:ok, path} = Pleroma.Export.run(user)
|
||||||
|
|
||||||
|
[path: path]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "S3", %{path: path} do
|
||||||
|
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.S3)
|
||||||
|
|
||||||
|
with_mock ExAws, request: fn _ -> {:ok, :ok} end do
|
||||||
assert {:ok, %Pleroma.Upload{}} = Pleroma.Export.upload(path)
|
assert {:ok, %Pleroma.Upload{}} = Pleroma.Export.upload(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "Local", %{path: path} do
|
||||||
|
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
|
||||||
|
|
||||||
|
assert {:ok, %Pleroma.Upload{}} = Pleroma.Export.upload(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue