diff options
author | Sir_Boops <admin@boops.me> | 2018-04-15 17:37:51 -0600 |
---|---|---|
committer | Sir_Boops <admin@boops.me> | 2018-06-06 13:25:44 -0600 |
commit | 3f0440ac3c38b88fe449da9b8281d1dbadfa36d1 (patch) | |
tree | cabecd884f53b8cac48b2d6ca5f541da7543b6f3 /test | |
parent | b5d8213e701a525903f4ac6b0654fdb1ed68b300 (diff) | |
download | pleroma-3f0440ac3c38b88fe449da9b8281d1dbadfa36d1.tar.gz pleroma-3f0440ac3c38b88fe449da9b8281d1dbadfa36d1.zip |
Dedupe uploads
Diffstat (limited to 'test')
-rw-r--r-- | test/upload_test.exs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/test/upload_test.exs b/test/upload_test.exs index d68b3e7ba..645f10293 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -3,40 +3,45 @@ defmodule Pleroma.UploadTest do use Pleroma.DataCase describe "Storing a file" do - test "copies the file to the configured folder" do + test "copies the file to the configured folder with deduping" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + file = %Plug.Upload{ content_type: "image/jpg", - path: Path.absname("test/fixtures/image.jpg"), + path: Path.absname("test/fixtures/image_tmp.jpg"), filename: "an [image.jpg" } - data = Upload.store(file) - assert data["name"] == "an [image.jpg" + data = Upload.store(file, true) - assert List.first(data["url"])["href"] == - "http://localhost:4001/media/#{data["uuid"]}/an%20%5Bimage.jpg" + assert data["name"] == + "e7a6d0cf595bff76f14c9a98b6c199539559e8b844e02e51e5efcfd1f614a2df.jpeg" end - test "fixes an incorrect content type" do + test "copies the file to the configured folder without deduping" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + file = %Plug.Upload{ - content_type: "application/octet-stream", - path: Path.absname("test/fixtures/image.jpg"), + content_type: "image/jpg", + path: Path.absname("test/fixtures/image_tmp.jpg"), filename: "an [image.jpg" } - data = Upload.store(file) - assert hd(data["url"])["mediaType"] == "image/jpeg" + data = Upload.store(file, false) + assert data["name"] == "an [image.jpg" end - test "does not modify a valid content type" do + test "fixes incorrect content type" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + file = %Plug.Upload{ - content_type: "image/png", - path: Path.absname("test/fixtures/image.jpg"), + content_type: "application/octet-stream", + path: Path.absname("test/fixtures/image_tmp.jpg"), filename: "an [image.jpg" } - data = Upload.store(file) - assert hd(data["url"])["mediaType"] == "image/png" + data = Upload.store(file, true) + assert hd(data["url"])["mediaType"] == "image/jpeg" end end end |