mobilizon.chapril.org-mobil.../test/mobilizon/media/media_test.exs
Thomas Citharel f90089e1bf
Refactor media upload
Use Upload Media logic from Pleroma

Backend changes for picture upload

Move AS <-> Model conversion to separate module

Front changes

Downgrade apollo-client: https://github.com/Akryum/vue-apollo/issues/577

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2019-05-24 17:29:51 +02:00

51 lines
1.4 KiB
Elixir

defmodule Mobilizon.MediaTest do
use Mobilizon.DataCase
alias Mobilizon.Media
import Mobilizon.Factory
describe "media" do
alias Mobilizon.Media.Picture
@valid_attrs %{
file: %{
url: "https://something.tld/media/something",
name: "something old"
}
}
@update_attrs %{
file: %{
url: "https://something.tld/media/something_updated",
name: "something new"
}
}
test "get_picture!/1 returns the picture with given id" do
picture = insert(:picture)
assert Media.get_picture!(picture.id) == picture
end
test "create_picture/1 with valid data creates a picture" do
assert {:ok, %Picture{} = picture} = Media.create_picture(@valid_attrs)
assert picture.file.name == "something old"
end
test "update_picture/2 with valid data updates the picture" do
picture = insert(:picture)
assert {:ok, %Picture{} = picture} = Media.update_picture(picture, @update_attrs)
assert picture.file.name == "something new"
end
test "delete_picture/1 deletes the picture" do
picture = insert(:picture)
assert {:ok, %Picture{}} = Media.delete_picture(picture)
assert_raise Ecto.NoResultsError, fn -> Media.get_picture!(picture.id) end
end
test "change_picture/1 returns a picture changeset" do
picture = insert(:picture)
assert %Ecto.Changeset{} = Media.change_picture(picture)
end
end
end