Add filesize to file entity, expose it to GraphQL API

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-06-03 17:13:47 +02:00
parent 4434459e59
commit 87bc5f8352
8 changed files with 66 additions and 18 deletions

View File

@@ -21,7 +21,9 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
picture(id: "#{id}") {
name,
alt,
url
url,
content_type,
size
}
}
"""
@@ -32,6 +34,11 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
assert json_response(res, 200)["data"]["picture"]["name"] == picture.file.name
assert json_response(res, 200)["data"]["picture"]["content_type"] ==
picture.file.content_type
assert json_response(res, 200)["data"]["picture"]["size"] == 13_120
assert json_response(res, 200)["data"]["picture"]["url"] =~
MobilizonWeb.Endpoint.url()
end
@@ -68,7 +75,9 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
actor_id: #{actor.id}
) {
url,
name
name,
content_type,
size
}
}
"""
@@ -91,6 +100,8 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
)
assert json_response(res, 200)["data"]["uploadPicture"]["name"] == picture.name
assert json_response(res, 200)["data"]["uploadPicture"]["content_type"] == "image/png"
assert json_response(res, 200)["data"]["uploadPicture"]["size"] == 10_097
assert json_response(res, 200)["data"]["uploadPicture"]["url"]
end