mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2026-02-15 17:16:57 +00:00
Elixir 1.19: Fix typing violation in MediaControllerTest
warning: a struct for Plug.Upload is expected on struct update:
%Plug.Upload{image | filename: "../../../../../nested/file.jpg"}
but got type:
dynamic()
where "image" was given the type:
# type: dynamic()
# from: test/pleroma/web/mastodon_api/controllers/media_controller_test.exs:132:42
%{conn: conn, image: image}
when defining the variable "image", you must also pattern match on "%Plug.Upload{}".
hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:
user = some_function()
%User{user | name: "John Doe"}
it is enough to write:
%User{} = user = some_function()
%{user | name: "John Doe"}
typing violation found at:
│
133 │ image = %Plug.Upload{
│ ~
│
└─ test/pleroma/web/mastodon_api/controllers/media_controller_test.exs:133:15: Pleroma.Web.MastodonAPI.MediaControllerTest."test Upload media Do not allow nested filename"/1
This commit is contained in:
parent
a051497b59
commit
b160a73924
1 changed files with 2 additions and 2 deletions
|
|
@ -129,8 +129,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
assert :ok == File.rm(Path.absname("test/tmp/large_binary.data"))
|
||||
end
|
||||
|
||||
test "Do not allow nested filename", %{conn: conn, image: image} do
|
||||
image = %Plug.Upload{
|
||||
test "Do not allow nested filename", %{conn: conn, image: %Plug.Upload{} = image} do
|
||||
image = %{
|
||||
image
|
||||
| filename: "../../../../../nested/file.jpg"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue