1
0
Fork 0
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 MarkerTest

warning: a struct for Pleroma.Marker is expected on struct update:

        %Pleroma.Marker{refresh_record(marker) | unread_count: 2}

    but got type:

        dynamic()

    where "marker" was given the type:

        # type: dynamic()
        # from: test/pleroma/marker_test.exs:35:14
        marker = Pleroma.Factory.insert(:marker, user: user)

    you must assign "refresh_record(marker)" to variable and pattern match on "%Pleroma.Marker{}".

    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:
    │
 43 │              ) == [%Marker{refresh_record(marker) | unread_count: 2}]
    │                    ~
    │
    └─ test/pleroma/marker_test.exs:43:20: Pleroma.MarkerTest."test get_markers/2 returns user markers"/1
This commit is contained in:
Phantasm 2026-01-09 16:48:55 +01:00
parent ecfcb47a09
commit 9eadc07361
No known key found for this signature in database
GPG key ID: 2669E588BCC634C8

View file

@ -36,11 +36,12 @@ defmodule Pleroma.MarkerTest do
insert(:notification, user: user, activity: insert(:note_activity))
insert(:notification, user: user, activity: insert(:note_activity))
insert(:marker, timeline: "home", user: user)
%Marker{} = refreshed_marker = refresh_record(marker)
assert Marker.get_markers(
user,
["notifications"]
) == [%Marker{refresh_record(marker) | unread_count: 2}]
) == [%{refreshed_marker | unread_count: 2}]
end
end