@@ -18,15 +18,15 @@ defmodule Plausible.Billing.Subscription.StatusTest do
1818 end
1919
2020 test "in?/2 returns true when subscription status is in list" do
21- assert in? ( % Plausible.Billing.Subscription { status: past_due ( ) } , [ active ( ) , past_due ( ) ] )
21+ assert in? ( subscription ( past_due ( ) ) , [ active ( ) , past_due ( ) ] )
2222 end
2323
2424 test "in?/2 returns false when subscription status is not in list" do
25- refute in? ( % Plausible.Billing.Subscription { status: paused ( ) } , [ active ( ) , past_due ( ) ] )
25+ refute in? ( subscription ( paused ( ) ) , [ active ( ) , past_due ( ) ] )
2626 end
2727
2828 test "in?/2 returns false when subscription is nil" do
29- refute in? ( nil , [ active ( ) , past_due ( ) ] )
29+ refute in? ( subscription ( nil ) , [ active ( ) , past_due ( ) ] )
3030 end
3131
3232 test "in?/2 raises ArgumentError when list includes invalid statuses" do
@@ -43,4 +43,22 @@ defmodule Plausible.Billing.Subscription.StatusTest do
4343 )
4444 end
4545 end
46+
47+ # Workaround for type checker in Elixir 1.20+ being
48+ # too smart about literals passed to macros.
49+ defp subscription ( nil ) do
50+ if :erlang . phash2 ( 1 , 1 ) == 0 do
51+ nil
52+ else
53+ % Plausible.Billing.Subscription { }
54+ end
55+ end
56+
57+ defp subscription ( status ) do
58+ if :erlang . phash2 ( 1 , 1 ) == 0 do
59+ % Plausible.Billing.Subscription { status: status }
60+ else
61+ nil
62+ end
63+ end
4664end
0 commit comments