Merge branch 'fix_flaky_test_user_relationship_test.exs_81' into 'develop'
fix flaky test_user_relationship_test.exs:81 See merge request pleroma/pleroma!3697
This commit is contained in:
commit
59109f8f74
|
@ -91,8 +91,9 @@ def create(relationship_type, %User{} = source, %User{} = target, expires_at \\
|
||||||
expires_at: expires_at
|
expires_at: expires_at
|
||||||
})
|
})
|
||||||
|> Repo.insert(
|
|> Repo.insert(
|
||||||
on_conflict: {:replace_all_except, [:id]},
|
on_conflict: {:replace_all_except, [:id, :inserted_at]},
|
||||||
conflict_target: [:source_id, :relationship_type, :target_id]
|
conflict_target: [:source_id, :relationship_type, :target_id],
|
||||||
|
returning: true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
defmodule Pleroma.UserRelationshipTest do
|
defmodule Pleroma.UserRelationshipTest do
|
||||||
alias Pleroma.UserRelationship
|
alias Pleroma.UserRelationship
|
||||||
|
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
|
|
||||||
|
import Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
describe "*_exists?/2" do
|
describe "*_exists?/2" do
|
||||||
|
@ -79,7 +80,12 @@ test "creates user relationship record if it doesn't exist", %{users: [user1, us
|
||||||
end
|
end
|
||||||
|
|
||||||
test "if record already exists, returns it", %{users: [user1, user2]} do
|
test "if record already exists, returns it", %{users: [user1, user2]} do
|
||||||
user_block = UserRelationship.create_block(user1, user2)
|
user_block =
|
||||||
|
with_mock NaiveDateTime, [:passthrough], utc_now: fn -> ~N[2017-03-17 17:09:58] end do
|
||||||
|
{:ok, %{inserted_at: ~N[2017-03-17 17:09:58]}} =
|
||||||
|
UserRelationship.create_block(user1, user2)
|
||||||
|
end
|
||||||
|
|
||||||
assert user_block == UserRelationship.create_block(user1, user2)
|
assert user_block == UserRelationship.create_block(user1, user2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue