1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.AnnouncementReadRelationshipTest do
6 alias Pleroma.AnnouncementReadRelationship
8 use Pleroma.DataCase, async: true
10 import Pleroma.Factory
13 {:ok, user: insert(:user), announcement: insert(:announcement)}
16 describe "mark_read/2" do
17 test "should insert relationship", %{user: user, announcement: announcement} do
18 {:ok, _} = AnnouncementReadRelationship.mark_read(user, announcement)
20 assert AnnouncementReadRelationship.exists?(user, announcement)
24 describe "mark_unread/2" do
25 test "should delete relationship", %{user: user, announcement: announcement} do
26 {:ok, _} = AnnouncementReadRelationship.mark_read(user, announcement)
28 assert :ok = AnnouncementReadRelationship.mark_unread(user, announcement)
29 refute AnnouncementReadRelationship.exists?(user, announcement)
32 test "should not fail if relationship does not exist", %{
34 announcement: announcement
36 assert :ok = AnnouncementReadRelationship.mark_unread(user, announcement)
37 refute AnnouncementReadRelationship.exists?(user, announcement)