@@ -4,36 +4,38 @@ use std::{error::Error, process::Command};
44
55#[ test]
66fn test_validate ( ) -> Result < ( ) , Box < dyn Error > > {
7+ let expected_output = r#"
8+ CODEOWNERS out of date. Run `codeowners generate` to update the CODEOWNERS file
9+
10+ Code ownership should only be defined for each file in one way. The following files have declared ownership in multiple ways
11+
12+ gems/payroll_calculator/calculator.rb
13+ owner: Payments
14+ - Owner annotation at the top of the file
15+ owner: Payroll
16+ - Owner specified in Team YML's `owned_gems`
17+
18+ ruby/app/services/multi_owned.rb
19+ owner: Payments
20+ - Owner annotation at the top of the file
21+ owner: Payroll
22+ - Owner specified in `ruby/app/services/.codeowner`
23+
24+ Found invalid team annotations
25+ - ruby/app/models/blockchain.rb is referencing an invalid team - 'Web3'
26+
27+ Some files are missing ownership
28+ - ruby/app/models/blockchain.rb
29+ - ruby/app/unowned.rb
30+ "#
31+ . trim ( ) ;
732 Command :: cargo_bin ( "codeowners" ) ?
833 . arg ( "--project-root" )
934 . arg ( "tests/fixtures/invalid_project" )
1035 . arg ( "validate" )
1136 . assert ( )
1237 . failure ( )
13- . stdout ( predicate:: str:: contains (
14- "CODEOWNERS out of date. Run `codeowners generate` to update the CODEOWNERS file" ,
15- ) )
16- . stdout ( predicate:: str:: contains (
17- "Some files are missing ownership\n - ruby/app/models/blockchain.rb\n - ruby/app/unowned.rb" ,
18- ) )
19- . stdout ( predicate:: str:: contains (
20- "Found invalid team annotations\n - ruby/app/models/blockchain.rb is referencing an invalid team - 'Web3'" ,
21- ) )
22- . stdout ( predicate:: str:: contains (
23- "Code ownership should only be defined for each file in one way. The following files have declared ownership in multiple ways" ,
24- ) )
25- . stdout ( predicate:: str:: contains (
26- "gems/payroll_calculator/calculator.rb (owner: Payments, source: Owner annotation at the top of the file)" ,
27- ) )
28- . stdout ( predicate:: str:: contains (
29- "gems/payroll_calculator/calculator.rb (owner: Payroll, source: Owner specified in Team YML's `owned_gems`)" ,
30- ) )
31- . stdout ( predicate:: str:: contains (
32- "ruby/app/services/multi_owned.rb (owner: Payments, source: Owner annotation at the top of the file)" ,
33- ) )
34- . stdout ( predicate:: str:: contains (
35- "ruby/app/services/multi_owned.rb (owner: Payroll, source: Owner specified in `ruby/app/services/.codeowner`" ,
36- ) ) ;
38+ . stdout ( predicate:: str:: contains ( expected_output) ) ;
3739
3840 Ok ( ( ) )
3941}
0 commit comments