Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.MarkerTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Marker
  7. import Pleroma.Factory
  8. describe "get_markers/2" do
  9. test "returns user markers" do
  10. user = insert(:user)
  11. marker = insert(:marker, user: user)
  12. insert(:marker, timeline: "home", user: user)
  13. assert Marker.get_markers(user, ["notifications"]) == [refresh_record(marker)]
  14. end
  15. end
  16. describe "upsert/2" do
  17. test "creates a marker" do
  18. user = insert(:user)
  19. {:ok, %{"notifications" => %Marker{} = marker}} =
  20. Marker.upsert(
  21. user,
  22. %{"notifications" => %{"last_read_id" => "34"}}
  23. )
  24. assert marker.timeline == "notifications"
  25. assert marker.last_read_id == "34"
  26. assert marker.lock_version == 0
  27. end
  28. test "updates exist marker" do
  29. user = insert(:user)
  30. marker = insert(:marker, user: user, last_read_id: "8909")
  31. {:ok, %{"notifications" => %Marker{}}} =
  32. Marker.upsert(
  33. user,
  34. %{"notifications" => %{"last_read_id" => "9909"}}
  35. )
  36. marker = refresh_record(marker)
  37. assert marker.timeline == "notifications"
  38. assert marker.last_read_id == "9909"
  39. assert marker.lock_version == 0
  40. end
  41. end
  42. end