@@ -176,120 +176,123 @@ mod tests {
176
176
177
177
use super :: * ;
178
178
179
+ fn p ( path : & str ) -> & Path {
180
+ Path :: new ( path)
181
+ }
182
+
179
183
#[ test]
180
184
fn test_is_valid_review_template_path_github ( ) {
181
- let valid_review_template_path_1 = Path :: new ( ".github/PULL_REQUEST_TEMPLATE.md" ) ;
182
- let valid_review_template_path_2 = Path :: new ( ".github/pull_request_template.md" ) ;
183
- let valid_review_template_path_3 = Path :: new ( ".github/PULL_REQUEST_TEMPLATE/something.md" ) ;
184
- let valid_review_template_path_4 = Path :: new ( ".docs/PULL_REQUEST_TEMPLATE.md" ) ;
185
- let valid_review_template_path_5 = Path :: new ( "PULL_REQUEST_TEMPLATE.md" ) ;
186
- let invalid_review_template_path = Path :: new ( "README.md" ) ;
187
-
188
- assert ! ( is_valid_review_template_path_github(
189
- valid_review_template_path_1,
190
- ) ) ;
191
- assert ! ( is_valid_review_template_path_github(
192
- valid_review_template_path_2,
193
- ) ) ;
194
- assert ! ( is_valid_review_template_path_github(
195
- valid_review_template_path_3,
196
- ) ) ;
197
- assert ! ( is_valid_review_template_path_github(
198
- valid_review_template_path_4,
199
- ) ) ;
200
- assert ! ( is_valid_review_template_path_github(
201
- valid_review_template_path_5,
202
- ) ) ;
203
- assert ! ( !is_valid_review_template_path_github(
204
- invalid_review_template_path,
205
- ) ) ;
185
+ assert ! ( is_valid_review_template_path_github( p(
186
+ ".github/PULL_REQUEST_TEMPLATE.md"
187
+ ) ) ) ;
188
+ assert ! ( is_valid_review_template_path_github( p(
189
+ ".github/pull_request_template.md"
190
+ ) ) ) ;
191
+ assert ! ( is_valid_review_template_path_github( p(
192
+ ".github/PULL_REQUEST_TEMPLATE/something.md"
193
+ ) ) ) ;
194
+ assert ! ( is_valid_review_template_path_github( p(
195
+ ".docs/PULL_REQUEST_TEMPLATE.md"
196
+ ) ) ) ;
197
+ assert ! ( is_valid_review_template_path_github( p(
198
+ "PULL_REQUEST_TEMPLATE.md"
199
+ ) ) ) ;
200
+ assert ! ( !is_valid_review_template_path_github( p( "README.md" ) , ) ) ;
206
201
}
207
202
208
203
#[ test]
209
204
fn test_is_valid_review_template_path_github_windows ( ) {
210
- let valid_review_template_path_1 = Path :: new ( ".github\\ PULL_REQUEST_TEMPLATE.md" ) ;
211
- let valid_review_template_path_2 = Path :: new ( ".github\\ pull_request_template.md" ) ;
212
- let valid_review_template_path_3 =
213
- Path :: new ( ".github\\ PULL_REQUEST_TEMPLATE\\ something.md" ) ;
214
- let valid_review_template_path_4 = Path :: new ( ".docs\\ PULL_REQUEST_TEMPLATE.md" ) ;
215
- let valid_review_template_path_5 = Path :: new ( "PULL_REQUEST_TEMPLATE.md" ) ;
216
- let invalid_review_template_path = Path :: new ( "README.md" ) ;
217
-
218
- assert ! ( is_valid_review_template_path_github(
219
- valid_review_template_path_1,
220
- ) ) ;
221
- assert ! ( is_valid_review_template_path_github(
222
- valid_review_template_path_2,
223
- ) ) ;
224
- assert ! ( is_valid_review_template_path_github(
225
- valid_review_template_path_3,
226
- ) ) ;
227
- assert ! ( is_valid_review_template_path_github(
228
- valid_review_template_path_4,
229
- ) ) ;
230
- assert ! ( is_valid_review_template_path_github(
231
- valid_review_template_path_5,
232
- ) ) ;
233
- assert ! ( !is_valid_review_template_path_github(
234
- invalid_review_template_path,
235
- ) ) ;
205
+ assert ! ( is_valid_review_template_path_github( p(
206
+ ".github\\ PULL_REQUEST_TEMPLATE.md"
207
+ ) , ) ) ;
208
+ assert ! ( is_valid_review_template_path_github( p(
209
+ ".github\\ pull_request_template.md"
210
+ ) , ) ) ;
211
+ assert ! ( is_valid_review_template_path_github( p(
212
+ ".github\\ PULL_REQUEST_TEMPLATE\\ something.md"
213
+ ) , ) ) ;
214
+ assert ! ( is_valid_review_template_path_github( p(
215
+ ".docs\\ PULL_REQUEST_TEMPLATE.md"
216
+ ) , ) ) ;
217
+ assert ! ( is_valid_review_template_path_github( p(
218
+ "PULL_REQUEST_TEMPLATE.md"
219
+ ) , ) ) ;
220
+ assert ! ( !is_valid_review_template_path_github( p( "README.md" ) , ) ) ;
236
221
}
237
222
238
223
#[ test]
239
224
fn test_is_valid_review_template_path_gitlab ( ) {
240
- let valid_review_template_path_1 = Path :: new ( ".gitlab/merge_request_templates/Default.md" ) ;
241
- let valid_review_template_path_2 = Path :: new ( ".gitlab/merge_request_templates/Documentation.md" ) ;
242
- let valid_review_template_path_3 = Path :: new ( ".gitlab/merge_request_templates/Security Fix.md" ) ;
243
- let invalid_review_template_path_1 = Path :: new ( "README.md" ) ;
244
- let invalid_review_template_path_2 = Path :: new ( ".gitlab/issue_templates/Bug.md" ) ;
245
- let invalid_review_template_path_3 = Path :: new ( ".gitlab/merge_request_templates/Default.txt" ) ;
246
-
247
- assert ! ( is_valid_review_template_path_gitlab( valid_review_template_path_1) ) ;
248
- assert ! ( is_valid_review_template_path_gitlab( valid_review_template_path_2) ) ;
249
- assert ! ( is_valid_review_template_path_gitlab( valid_review_template_path_3) ) ;
250
- assert ! ( !is_valid_review_template_path_gitlab( invalid_review_template_path_1) ) ;
251
- assert ! ( !is_valid_review_template_path_gitlab( invalid_review_template_path_2) ) ;
252
- assert ! ( !is_valid_review_template_path_gitlab( invalid_review_template_path_3) ) ;
225
+ assert ! ( is_valid_review_template_path_gitlab( p(
226
+ ".gitlab/merge_request_templates/Default.md"
227
+ ) ) ) ;
228
+ assert ! ( is_valid_review_template_path_gitlab( p(
229
+ ".gitlab/merge_request_templates/Documentation.md"
230
+ ) ) ) ;
231
+ assert ! ( is_valid_review_template_path_gitlab( p(
232
+ ".gitlab/merge_request_templates/Security Fix.md"
233
+ ) ) ) ;
234
+ assert ! ( !is_valid_review_template_path_gitlab( p( "README.md" ) ) ) ;
235
+ assert ! ( !is_valid_review_template_path_gitlab( p(
236
+ ".gitlab/issue_templates/Bug.md"
237
+ ) ) ) ;
238
+ assert ! ( !is_valid_review_template_path_gitlab( p(
239
+ ".gitlab/merge_request_templates/Default.txt"
240
+ ) ) ) ;
253
241
}
254
242
255
243
#[ test]
256
244
fn test_is_valid_review_template_path_gitlab_windows ( ) {
257
- let valid_review_template_path_1 = Path :: new ( ".gitlab\\ merge_request_templates\\ Default.md" ) ;
258
- let valid_review_template_path_2 = Path :: new ( ".gitlab\\ merge_request_templates\\ Documentation.md" ) ;
259
- let valid_review_template_path_3 = Path :: new ( ".gitlab\\ merge_request_templates\\ Security Fix.md" ) ;
260
- let invalid_review_template_path_1 = Path :: new ( "README.md" ) ;
261
- let invalid_review_template_path_2 = Path :: new ( ".gitlab\\ issue_templates\\ Bug.md" ) ;
262
- let invalid_review_template_path_3 = Path :: new ( ".gitlab\\ merge_request_templates\\ Default.txt" ) ;
263
-
264
- assert ! ( is_valid_review_template_path_gitlab( valid_review_template_path_1) ) ;
265
- assert ! ( is_valid_review_template_path_gitlab( valid_review_template_path_2) ) ;
266
- assert ! ( is_valid_review_template_path_gitlab( valid_review_template_path_3) ) ;
267
- assert ! ( !is_valid_review_template_path_gitlab( invalid_review_template_path_1) ) ;
268
- assert ! ( !is_valid_review_template_path_gitlab( invalid_review_template_path_2) ) ;
269
- assert ! ( !is_valid_review_template_path_gitlab( invalid_review_template_path_3) ) ;
245
+ assert ! ( is_valid_review_template_path_gitlab( p(
246
+ ".gitlab\\ merge_request_templates\\ Default.md"
247
+ ) ) ) ;
248
+ assert ! ( is_valid_review_template_path_gitlab( p(
249
+ ".gitlab\\ merge_request_templates\\ Documentation.md"
250
+ ) ) ) ;
251
+ assert ! ( is_valid_review_template_path_gitlab( p(
252
+ ".gitlab\\ merge_request_templates\\ Security Fix.md"
253
+ ) ) ) ;
254
+ assert ! ( !is_valid_review_template_path_gitlab( p( "README.md" ) ) ) ;
255
+ assert ! ( !is_valid_review_template_path_gitlab( p(
256
+ ".gitlab\\ issue_templates\\ Bug.md"
257
+ ) ) ) ;
258
+ assert ! ( !is_valid_review_template_path_gitlab( p(
259
+ ".gitlab\\ merge_request_templates\\ Default.txt"
260
+ ) ) ) ;
270
261
}
271
262
272
263
#[ test]
273
264
fn test_get_gitlab_directory_path ( ) {
274
- let root_path = Path :: new ( "/path/to/project" ) ;
265
+ let root_path = p ( "/path/to/project" ) ;
275
266
let gitlab_path = get_gitlab_directory_path ( root_path) ;
276
- assert_eq ! ( gitlab_path, Path :: new ( "/path/to/project/.gitlab" ) ) ;
267
+ assert_eq ! ( gitlab_path, p ( "/path/to/project/.gitlab" ) ) ;
277
268
}
278
269
279
270
#[ test]
280
271
fn test_is_review_template_gitlab ( ) {
281
272
// Valid GitLab merge request templates
282
- assert ! ( is_review_template_gitlab( ".gitlab/merge_request_templates/Default.md" ) ) ;
283
- assert ! ( is_review_template_gitlab( ".gitlab/merge_request_templates/Documentation.md" ) ) ;
284
- assert ! ( is_review_template_gitlab( ".gitlab/merge_request_templates/Security Fix.md" ) ) ;
285
-
273
+ assert ! ( is_review_template_gitlab(
274
+ ".gitlab/merge_request_templates/Default.md"
275
+ ) ) ;
276
+ assert ! ( is_review_template_gitlab(
277
+ ".gitlab/merge_request_templates/Documentation.md"
278
+ ) ) ;
279
+ assert ! ( is_review_template_gitlab(
280
+ ".gitlab/merge_request_templates/Security Fix.md"
281
+ ) ) ;
282
+
286
283
// Invalid paths
287
284
assert ! ( !is_review_template_gitlab( "README.md" ) ) ;
288
285
assert ! ( !is_review_template_gitlab( ".gitlab/issue_templates/Bug.md" ) ) ;
289
- assert ! ( !is_review_template_gitlab( ".gitlab/merge_request_templates/Default.txt" ) ) ;
290
- assert ! ( !is_review_template_gitlab( "merge_request_templates/Default.md" ) ) ;
291
-
286
+ assert ! ( !is_review_template_gitlab(
287
+ ".gitlab/merge_request_templates/Default.txt"
288
+ ) ) ;
289
+ assert ! ( !is_review_template_gitlab(
290
+ "merge_request_templates/Default.md"
291
+ ) ) ;
292
+
292
293
// Windows path separators should work
293
- assert ! ( is_review_template_gitlab( ".gitlab\\ merge_request_templates\\ Default.md" ) ) ;
294
+ assert ! ( is_review_template_gitlab(
295
+ ".gitlab\\ merge_request_templates\\ Default.md"
296
+ ) ) ;
294
297
}
295
298
}
0 commit comments