@@ -47,57 +47,66 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
4747
4848 @ tag user: @ unauthorized_user
4949 test "handles bounty command with unauthorized user" , % { user: user } do
50- assert process_bounty_command ( "/bounty $100" , user ) [ :ok ] == nil
51- assert process_bounty_command ( "/bounty $100" , user ) [ :error ] == :unauthorized
50+ assert { :error , :unauthorized } = process_bounty_command ( "/bounty $100" , user )
5251 end
5352
5453 test "handles bounty command without amount" do
55- assert process_bounty_command ( "/bounty" ) [ :ok ] == nil
56- assert process_bounty_command ( "/bounty" ) [ :error ] == nil
54+ assert { :ok , [ ] } = process_bounty_command ( "/bounty" )
5755 end
5856
5957 test "handles valid bounty command with $ prefix" do
60- assert process_bounty_command ( "/bounty $100" ) [ :ok ] . amount == ~M[ 100] usd
58+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty $100" )
59+ assert bounty . amount == ~M[ 100] usd
6160 end
6261
6362 test "handles invalid bounty command with $ suffix" do
64- assert process_bounty_command ( "/bounty 100$" ) [ :ok ] . amount == ~M[ 100] usd
63+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 100$" )
64+ assert bounty . amount == ~M[ 100] usd
6565 end
6666
6767 test "handles bounty command without $ symbol" do
68- assert process_bounty_command ( "/bounty 100" ) [ :ok ] . amount == ~M[ 100] usd
68+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 100" )
69+ assert bounty . amount == ~M[ 100] usd
6970 end
7071
7172 test "handles bounty command with decimal amount" do
72- assert process_bounty_command ( "/bounty 100.50" ) [ :ok ] . amount == ~M[ 100.50] usd
73+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 100.50" )
74+ assert bounty . amount == ~M[ 100.50] usd
7375 end
7476
7577 test "handles bounty command with partial decimal amount" do
76- assert process_bounty_command ( "/bounty 100.5" ) [ :ok ] . amount == ~M[ 100.5] usd
78+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 100.5" )
79+ assert bounty . amount == ~M[ 100.5] usd
7780 end
7881
7982 test "handles bounty command with decimal amount and $ prefix" do
80- assert process_bounty_command ( "/bounty $100.50" ) [ :ok ] . amount == ~M[ 100.50] usd
83+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty $100.50" )
84+ assert bounty . amount == ~M[ 100.50] usd
8185 end
8286
8387 test "handles bounty command with partial decimal amount and $ prefix" do
84- assert process_bounty_command ( "/bounty $100.5" ) [ :ok ] . amount == ~M[ 100.5] usd
88+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty $100.5" )
89+ assert bounty . amount == ~M[ 100.5] usd
8590 end
8691
8792 test "handles bounty command with decimal amount and $ suffix" do
88- assert process_bounty_command ( "/bounty 100.50$" ) [ :ok ] . amount == ~M[ 100.50] usd
93+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 100.50$" )
94+ assert bounty . amount == ~M[ 100.50] usd
8995 end
9096
9197 test "handles bounty command with partial decimal amount and $ suffix" do
92- assert process_bounty_command ( "/bounty 100.5$" ) [ :ok ] . amount == ~M[ 100.5] usd
98+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 100.5$" )
99+ assert bounty . amount == ~M[ 100.5] usd
93100 end
94101
95102 test "handles bounty command with comma separator" do
96- assert process_bounty_command ( "/bounty 1,000" ) [ :ok ] . amount == ~M[ 1000] usd
103+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 1,000" )
104+ assert bounty . amount == ~M[ 1000] usd
97105 end
98106
99107 test "handles bounty command with comma separator and decimal amount" do
100- assert process_bounty_command ( "/bounty 1,000.50" ) [ :ok ] . amount == ~M[ 1000.50] usd
108+ assert { :ok , [ bounty ] } = process_bounty_command ( "/bounty 1,000.50" )
109+ assert bounty . amount == ~M[ 1000.50] usd
101110 end
102111 end
103112
@@ -184,14 +193,17 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
184193 end
185194
186195 # Helper function to process bounty commands
187- defp process_bounty_command ( body , author \\ @ admin_user ) do
188- full_body = """
196+ defp process_bounty_command ( command , author \\ @ admin_user ) do
197+ body = """
189198 Lorem
190- ipsum #{ body } dolor
199+ ipsum #{ command } dolor
191200 sit
192201 amet
193202 """
194203
195- GithubController . process_commands ( full_body , % { "login" => author } , @ params )
204+ GithubController . process_commands (
205+ "issue_comment" ,
206+ Map . put ( @ params , "comment" , % { "user" => % { "login" => author } , "body" => body } )
207+ )
196208 end
197209end
0 commit comments