-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinvalid_project_test.rs
More file actions
89 lines (77 loc) · 2.65 KB
/
invalid_project_test.rs
File metadata and controls
89 lines (77 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use assert_cmd::prelude::*;
use indoc::indoc;
use predicates::prelude::*;
use std::{error::Error, process::Command};
#[test]
fn test_validate() -> Result<(), Box<dyn Error>> {
Command::cargo_bin("codeowners")?
.arg("--project-root")
.arg("tests/fixtures/invalid_project")
.arg("--no-cache")
.arg("validate")
.assert()
.failure()
.stdout(predicate::eq(indoc! {"
CODEOWNERS out of date. Run `codeowners generate` to update the CODEOWNERS file
Code ownership should only be defined for each file in one way. The following files have declared ownership in multiple ways
gems/payroll_calculator/calculator.rb
owner: Payments
- Owner annotation at the top of the file
owner: Payroll
- Owner specified in Team YML's `owned_gems`
ruby/app/services/multi_owned.rb
owner: Payments
- Owner annotation at the top of the file
owner: Payroll
- Owner specified in `ruby/app/services/.codeowner`
Found invalid team annotations
- ruby/app/models/blockchain.rb is referencing an invalid team - 'Web3'
Some files are missing ownership
- ruby/app/unowned.rb
"}));
Ok(())
}
#[test]
fn test_for_file() -> Result<(), Box<dyn Error>> {
Command::cargo_bin("codeowners")?
.arg("--project-root")
.arg("tests/fixtures/invalid_project")
.arg("--no-cache")
.arg("for-file")
.arg("ruby/app/models/blockchain.rb")
.assert()
.success()
.stdout(predicate::eq(indoc! {"
Team: Unowned
Github Team: Unowned
Team YML:
Description:
- Unowned
"}));
Ok(())
}
#[test]
fn test_for_file_multiple_owners() -> Result<(), Box<dyn Error>> {
Command::cargo_bin("codeowners")?
.arg("--project-root")
.arg("tests/fixtures/invalid_project")
.arg("--no-cache")
.arg("for-file")
.arg("ruby/app/services/multi_owned.rb")
.assert()
.failure()
.stdout(predicate::eq(indoc! {"
Error: file is owned by multiple teams!
Team: Payments
Github Team: @PaymentTeam
Team YML: config/teams/payments.yml
Description:
- Owner annotation at the top of the file
Team: Payroll
Github Team: @PayrollTeam
Team YML: config/teams/payroll.yml
Description:
- Owner specified in `ruby/app/services/.codeowner`
"}));
Ok(())
}