Delete attachments when status is deleted
This commit is contained in:
parent
8b4d81609d
commit
88f0eed0f2
8 changed files with 214 additions and 1 deletions
|
|
@ -29,4 +29,25 @@ defmodule Pleroma.Uploaders.LocalTest do
|
|||
|> File.exists?()
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete_file/1" do
|
||||
test "deletes local file" do
|
||||
file_path = "local_upload/files/image.jpg"
|
||||
|
||||
file = %Pleroma.Upload{
|
||||
name: "image.jpg",
|
||||
content_type: "image/jpg",
|
||||
path: file_path,
|
||||
tempfile: Path.absname("test/fixtures/image_tmp.jpg")
|
||||
}
|
||||
|
||||
:ok = Local.put_file(file)
|
||||
local_path = Path.join([Local.upload_path(), file_path])
|
||||
assert File.exists?(local_path)
|
||||
|
||||
Local.delete_file(file_path)
|
||||
|
||||
refute File.exists?(local_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -79,4 +79,11 @@ defmodule Pleroma.Uploaders.S3Test do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete_file/1" do
|
||||
test_with_mock "deletes file", ExAws, request: fn _req -> {:ok, %{status_code: 204}} end do
|
||||
assert :ok = S3.delete_file("image.jpg")
|
||||
assert_called(ExAws.request(:_))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue