@@ -206,6 +206,7 @@ fn parse_for_team(team_name: String, codeowners_file: &str) -> Result<Vec<TeamOw
206
206
mod tests {
207
207
use super :: * ;
208
208
use crate :: common_test:: tests:: { build_ownership_with_all_mappers, vecs_match} ;
209
+ use indoc:: indoc;
209
210
210
211
#[ test]
211
212
fn test_for_file_owner ( ) -> Result < ( ) , Box < dyn Error > > {
@@ -243,17 +244,17 @@ mod tests {
243
244
244
245
#[ test]
245
246
fn test_parse_for_team_trims_header ( ) -> Result < ( ) , Box < dyn Error > > {
246
- let codeownership_file = r# "
247
- # STOP! - DO NOT EDIT THIS FILE MANUALLY
248
- # This file was automatically generated by "bin/codeownership validate".
249
- #
250
- # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub
251
- # teams. This is useful when developers create Pull Requests since the
252
- # code/file owner is notified. Reference GitHub docs for more details:
253
- # https://help.github.com/en/articles/about-code-owners
247
+ let codeownership_file = indoc ! { "
248
+ # STOP! - DO NOT EDIT THIS FILE MANUALLY
249
+ # This file was automatically generated by \ " bin/codeownership validate\ " .
250
+ #
251
+ # CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub
252
+ # teams. This is useful when developers create Pull Requests since the
253
+ # code/file owner is notified. Reference GitHub docs for more details:
254
+ # https://help.github.com/en/articles/about-code-owners
254
255
255
256
256
- "# ;
257
+ " } ;
257
258
258
259
let team_ownership = parse_for_team ( "@Bar" . to_string ( ) , codeownership_file) ?;
259
260
assert ! ( team_ownership. is_empty( ) ) ;
@@ -262,14 +263,14 @@ mod tests {
262
263
263
264
#[ test]
264
265
fn test_parse_for_team_includes_owned_globs ( ) -> Result < ( ) , Box < dyn Error > > {
265
- let codeownership_file = r# "
266
- # First Section
267
- /path/to/owned @Foo
268
- /path/to/not/owned @Bar
266
+ let codeownership_file = indoc ! { "
267
+ # First Section
268
+ /path/to/owned @Foo
269
+ /path/to/not/owned @Bar
269
270
270
- # Last Section
271
- /another/owned/path @Foo
272
- "# ;
271
+ # Last Section
272
+ /another/owned/path @Foo
273
+ " } ;
273
274
274
275
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ?;
275
276
vecs_match (
@@ -290,11 +291,11 @@ mod tests {
290
291
291
292
#[ test]
292
293
fn test_parse_for_team_with_partial_team_match ( ) -> Result < ( ) , Box < dyn Error > > {
293
- let codeownership_file = r# "
294
- # First Section
295
- /path/to/owned @Foo
296
- /path/to/not/owned @FooBar
297
- "# ;
294
+ let codeownership_file = indoc ! { "
295
+ # First Section
296
+ /path/to/owned @Foo
297
+ /path/to/not/owned @FooBar
298
+ " } ;
298
299
299
300
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ?;
300
301
vecs_match (
@@ -309,16 +310,16 @@ mod tests {
309
310
310
311
#[ test]
311
312
fn test_parse_for_team_with_trailing_newlines ( ) -> Result < ( ) , Box < dyn Error > > {
312
- let codeownership_file = r# "
313
- # First Section
314
- /path/to/owned @Foo
313
+ let codeownership_file = indoc ! { "
314
+ # First Section
315
+ /path/to/owned @Foo
315
316
316
- # Last Section
317
- /another/owned/path @Foo
317
+ # Last Section
318
+ /another/owned/path @Foo
318
319
319
320
320
321
321
- "# ;
322
+ " } ;
322
323
323
324
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ?;
324
325
vecs_match (
@@ -339,9 +340,9 @@ mod tests {
339
340
340
341
#[ test]
341
342
fn test_parse_for_team_without_trailing_newline ( ) -> Result < ( ) , Box < dyn Error > > {
342
- let codeownership_file = r# "
343
- # First Section
344
- /path/to/owned @Foo"# ;
343
+ let codeownership_file = indoc ! { "
344
+ # First Section
345
+ /path/to/owned @Foo"} ;
345
346
346
347
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ?;
347
348
vecs_match (
@@ -356,12 +357,12 @@ mod tests {
356
357
357
358
#[ test]
358
359
fn test_parse_for_team_with_missing_section_header ( ) -> Result < ( ) , Box < dyn Error > > {
359
- let codeownership_file = r# "
360
- # First Section
361
- /path/to/owned @Foo
360
+ let codeownership_file = indoc ! { "
361
+ # First Section
362
+ /path/to/owned @Foo
362
363
363
- /another/owned/path @Foo
364
- "# ;
364
+ /another/owned/path @Foo
365
+ " } ;
365
366
366
367
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ;
367
368
assert ! ( team_ownership
@@ -371,10 +372,10 @@ mod tests {
371
372
372
373
#[ test]
373
374
fn test_parse_for_team_with_malformed_team_line ( ) -> Result < ( ) , Box < dyn Error > > {
374
- let codeownership_file = r# "
375
- # First Section
376
- @Foo
377
- "# ;
375
+ let codeownership_file = indoc ! { "
376
+ # First Section
377
+ @Foo
378
+ " } ;
378
379
379
380
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ;
380
381
assert ! ( team_ownership
@@ -384,11 +385,11 @@ mod tests {
384
385
385
386
#[ test]
386
387
fn test_parse_for_team_with_invalid_file ( ) -> Result < ( ) , Box < dyn Error > > {
387
- let codeownership_file = r# "
388
- # First Section
389
- # Second Section
390
- path/to/owned @Foo
391
- "# ;
388
+ let codeownership_file = indoc ! { "
389
+ # First Section
390
+ # Second Section
391
+ path/to/owned @Foo
392
+ " } ;
392
393
let team_ownership = parse_for_team ( "@Foo" . to_string ( ) , codeownership_file) ?;
393
394
vecs_match (
394
395
& team_ownership,
0 commit comments