Fix tests relying on old behavior. Use the Upload.base_url, Luke.

This commit is contained in:
Mark Felder 2021-01-12 16:35:10 -06:00
parent c35e6fb516
commit e87cca97e6
3 changed files with 13 additions and 8 deletions

View File

@ -148,8 +148,8 @@ defmodule Pleroma.UploadTest do
{:ok, data} = Upload.store(file, filters: [Pleroma.Upload.Filter.Dedupe])
assert List.first(data["url"])["href"] ==
Pleroma.Web.base_url() <>
"/media/e30397b58d226d6583ab5b8b3c5defb0c682bda5c31ef07a9f57c1c4986e3781.jpg"
Pleroma.Upload.base_url() <>
"e30397b58d226d6583ab5b8b3c5defb0c682bda5c31ef07a9f57c1c4986e3781.jpg"
end
test "copies the file to the configured folder without deduping" do

View File

@ -16,9 +16,12 @@ defmodule Pleroma.Uploaders.S3Test do
uploader: Pleroma.Uploaders.S3
)
clear_config(Pleroma.Upload,
base_url: "https://s3.amazonaws.com"
)
clear_config(Pleroma.Uploaders.S3,
bucket: "test_bucket",
public_endpoint: "https://s3.amazonaws.com"
bucket: "test_bucket"
)
end
@ -33,10 +36,11 @@ defmodule Pleroma.Uploaders.S3Test do
test "it returns path without bucket when truncated_namespace set to ''" do
Config.put([Pleroma.Uploaders.S3],
bucket: "test_bucket",
public_endpoint: "https://s3.amazonaws.com",
truncated_namespace: ""
)
Config.put([Pleroma.Upload], base_url: "https://s3.amazonaws.com")
assert S3.get_file("test_image.jpg") == {
:ok,
{:url, "https://s3.amazonaws.com/test_image.jpg"}
@ -46,10 +50,11 @@ defmodule Pleroma.Uploaders.S3Test do
test "it returns path with bucket namespace when namespace is set" do
Config.put([Pleroma.Uploaders.S3],
bucket: "test_bucket",
public_endpoint: "https://s3.amazonaws.com",
bucket_namespace: "family"
)
Config.put([Pleroma.Upload], base_url: "https://s3.amazonaws.com")
assert S3.get_file("test_image.jpg") == {
:ok,
{:url, "https://s3.amazonaws.com/family:test_bucket/test_image.jpg"}

View File

@ -196,11 +196,11 @@ defmodule Pleroma.User.BackupTest do
describe "it uploads and deletes a backup archive" do
setup do
clear_config(Pleroma.Uploaders.S3,
bucket: "test_bucket",
public_endpoint: "https://s3.amazonaws.com"
bucket: "test_bucket"
)
clear_config([Pleroma.Upload, :uploader])
clear_config([Pleroma.Upload, base_url: "https://s3.amazonaws.com"])
user = insert(:user, %{nickname: "cofe", name: "Cofe", ap_id: "http://cofe.io/users/cofe"})