@@ -62,117 +62,109 @@ pub(super) async fn command_info(
62
62
63
63
#[ cfg( test) ]
64
64
mod tests {
65
- use crate :: tests:: mocks:: { create_world_with_approve_config , BorsBuilder , World } ;
65
+ use crate :: tests:: mocks:: run_test ;
66
66
67
67
#[ sqlx:: test]
68
68
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"
76
74
- **Not Approved:**
77
75
- **Priority:** Not set
78
76
"
79
- ) ;
80
- Ok ( tester)
81
- } )
82
- . await ;
77
+ ) ;
78
+ Ok ( tester)
79
+ } )
80
+ . await ;
83
81
}
84
82
85
83
#[ sqlx:: test]
86
84
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"
97
93
- **Approved by:** @default-user
98
94
- **Priority:** Not set
99
95
"
100
- ) ;
101
- Ok ( tester)
102
- } )
103
- . await ;
96
+ ) ;
97
+ Ok ( tester)
98
+ } )
99
+ . await ;
104
100
}
105
101
106
102
#[ sqlx:: test]
107
103
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"
123
119
- **Not Approved:**
124
120
- **Priority:** 5
125
121
"
126
- ) ;
127
- Ok ( tester)
128
- } )
129
- . await ;
122
+ ) ;
123
+ Ok ( tester)
124
+ } )
125
+ . await ;
130
126
}
131
127
132
128
#[ sqlx:: test]
133
129
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"
144
138
- **Not Approved:**
145
139
- **Priority:** Not set
146
140
- **Try build branch:** automation/bors/try
147
141
"
148
- ) ;
149
- Ok ( tester)
150
- } )
151
- . await ;
142
+ ) ;
143
+ Ok ( tester)
144
+ } )
145
+ . await ;
152
146
}
153
147
154
148
#[ sqlx:: test]
155
149
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"
169
161
- **Approved by:** @default-user
170
162
- **Priority:** 10
171
163
- **Try build branch:** automation/bors/try
172
164
"
173
- ) ;
174
- Ok ( tester)
175
- } )
176
- . await ;
165
+ ) ;
166
+ Ok ( tester)
167
+ } )
168
+ . await ;
177
169
}
178
170
}
0 commit comments