Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Jul 7, 2024
1 parent ada61fa commit a9525c1
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions test/let_me/policy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,23 @@ defmodule LetMe.PolicyTest do
Policy.filter_allowed_actions(rules, %{id: 2}, object)

assert [%Rule{name: :article_create}, %Rule{name: :article_view}] =
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :writer},
object
Enum.sort_by(
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :writer},
object
),
& &1.name
)

assert [%Rule{name: :article_create}, %Rule{name: :article_view}] =
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :admin},
object
Enum.sort_by(
Policy.filter_allowed_actions(
rules,
%{id: 2, role: :admin},
object
),
& &1.name
)

assert [
Expand All @@ -284,7 +290,7 @@ defmodule LetMe.PolicyTest do
%{id: 1, role: :admin},
object
)
|> Enum.sort()
|> Enum.sort_by(& &1.name)

assert [%Rule{name: :article_update}, %Rule{name: :article_view}] =
Policy.filter_allowed_actions(rules, %{id: 1}, object)
Expand Down

0 comments on commit a9525c1

Please sign in to comment.