@@ -62,117 +62,109 @@ pub(super) async fn command_info(
6262
6363#[ cfg( test) ]
6464mod tests {
65- use crate :: tests:: mocks:: { create_world_with_approve_config , BorsBuilder , World } ;
65+ use crate :: tests:: mocks:: run_test ;
6666
6767 #[ sqlx:: test]
6868 async fn info_for_unapproved_pr ( pool : sqlx:: PgPool ) {
69- BorsBuilder :: new ( pool)
70- . world ( World :: default ( ) )
71- . run_test ( |mut tester| async {
72- tester. post_comment ( "@bors info" ) . await ?;
73- insta:: assert_snapshot!(
74- tester. get_comment( ) . await ?,
75- @r"
69+ run_test ( pool, |mut tester| async {
70+ tester. post_comment ( "@bors info" ) . await ?;
71+ insta:: assert_snapshot!(
72+ tester. get_comment( ) . await ?,
73+ @r"
7674 - **Not Approved:**
7775 - **Priority:** Not set
7876 "
79- ) ;
80- Ok ( tester)
81- } )
82- . await ;
77+ ) ;
78+ Ok ( tester)
79+ } )
80+ . await ;
8381 }
8482
8583 #[ sqlx:: test]
8684 async fn info_for_approved_pr ( pool : sqlx:: PgPool ) {
87- BorsBuilder :: new ( pool)
88- . world ( create_world_with_approve_config ( ) )
89- . run_test ( |mut tester| async {
90- tester. post_comment ( "@bors r+" ) . await ?;
91- tester. expect_comments ( 1 ) . await ;
92-
93- tester. post_comment ( "@bors info" ) . await ?;
94- insta:: assert_snapshot!(
95- tester. get_comment( ) . await ?,
96- @r"
85+ run_test ( pool, |mut tester| async {
86+ tester. post_comment ( "@bors r+" ) . await ?;
87+ tester. expect_comments ( 1 ) . await ;
88+
89+ tester. post_comment ( "@bors info" ) . await ?;
90+ insta:: assert_snapshot!(
91+ tester. get_comment( ) . await ?,
92+ @r"
9793 - **Approved by:** @default-user
9894 - **Priority:** Not set
9995 "
100- ) ;
101- Ok ( tester)
102- } )
103- . await ;
96+ ) ;
97+ Ok ( tester)
98+ } )
99+ . await ;
104100 }
105101
106102 #[ sqlx:: test]
107103 async fn info_for_pr_with_priority ( pool : sqlx:: PgPool ) {
108- BorsBuilder :: new ( pool)
109- . world ( create_world_with_approve_config ( ) )
110- . run_test ( | mut tester| async {
111- tester . post_comment ( "@bors p=5" ) . await ? ;
112- tester
113- . wait_for ( || async {
114- let pr = tester . get_default_pr ( ) . await ? ;
115- Ok ( pr. priority == Some ( 5 ) )
116- } )
117- . await ?;
118-
119- tester. post_comment ( "@bors info" ) . await ?;
120- insta:: assert_snapshot!(
121- tester. get_comment( ) . await ?,
122- @r"
104+ run_test ( pool, | mut tester| async {
105+ tester . post_comment ( "@bors p=5" ) . await ? ;
106+ tester
107+ . wait_for ( || async {
108+ let Some ( pr ) = tester. default_pr_db ( ) . await ? else {
109+ return Ok ( false ) ;
110+ } ;
111+ Ok ( pr. priority == Some ( 5 ) )
112+ } )
113+ . await ?;
114+
115+ tester. post_comment ( "@bors info" ) . await ?;
116+ insta:: assert_snapshot!(
117+ tester. get_comment( ) . await ?,
118+ @r"
123119 - **Not Approved:**
124120 - **Priority:** 5
125121 "
126- ) ;
127- Ok ( tester)
128- } )
129- . await ;
122+ ) ;
123+ Ok ( tester)
124+ } )
125+ . await ;
130126 }
131127
132128 #[ sqlx:: test]
133129 async fn info_for_pr_with_try_build ( pool : sqlx:: PgPool ) {
134- BorsBuilder :: new ( pool)
135- . world ( create_world_with_approve_config ( ) )
136- . run_test ( |mut tester| async {
137- tester. post_comment ( "@bors try" ) . await ?;
138- tester. expect_comments ( 1 ) . await ;
139-
140- tester. post_comment ( "@bors info" ) . await ?;
141- insta:: assert_snapshot!(
142- tester. get_comment( ) . await ?,
143- @r"
130+ run_test ( pool, |mut tester| async {
131+ tester. post_comment ( "@bors try" ) . await ?;
132+ tester. expect_comments ( 1 ) . await ;
133+
134+ tester. post_comment ( "@bors info" ) . await ?;
135+ insta:: assert_snapshot!(
136+ tester. get_comment( ) . await ?,
137+ @r"
144138 - **Not Approved:**
145139 - **Priority:** Not set
146140 - **Try build branch:** automation/bors/try
147141 "
148- ) ;
149- Ok ( tester)
150- } )
151- . await ;
142+ ) ;
143+ Ok ( tester)
144+ } )
145+ . await ;
152146 }
153147
154148 #[ sqlx:: test]
155149 async fn info_for_pr_with_everything ( pool : sqlx:: PgPool ) {
156- BorsBuilder :: new ( pool)
157- . world ( create_world_with_approve_config ( ) )
158- . run_test ( |mut tester| async {
159- tester. post_comment ( "@bors r+ p=10" ) . await ?;
160- tester. expect_comments ( 1 ) . await ;
161-
162- tester. post_comment ( "@bors try" ) . await ?;
163- tester. expect_comments ( 1 ) . await ;
164-
165- tester. post_comment ( "@bors info" ) . await ?;
166- insta:: assert_snapshot!(
167- tester. get_comment( ) . await ?,
168- @r"
150+ run_test ( pool, |mut tester| async {
151+ tester. post_comment ( "@bors r+ p=10" ) . await ?;
152+ tester. expect_comments ( 1 ) . await ;
153+
154+ tester. post_comment ( "@bors try" ) . await ?;
155+ tester. expect_comments ( 1 ) . await ;
156+
157+ tester. post_comment ( "@bors info" ) . await ?;
158+ insta:: assert_snapshot!(
159+ tester. get_comment( ) . await ?,
160+ @r"
169161 - **Approved by:** @default-user
170162 - **Priority:** 10
171163 - **Try build branch:** automation/bors/try
172164 "
173- ) ;
174- Ok ( tester)
175- } )
176- . await ;
165+ ) ;
166+ Ok ( tester)
167+ } )
168+ . await ;
177169 }
178170}
0 commit comments