-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinvalid_project_test.rs
More file actions
174 lines (158 loc) · 5.06 KB
/
Copy pathinvalid_project_test.rs
File metadata and controls
174 lines (158 loc) · 5.06 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
use indoc::indoc;
use predicates::prelude::*;
use std::error::Error;
mod common;
use common::OutputStream;
use common::run_codeowners;
#[test]
fn test_validate() -> Result<(), Box<dyn Error>> {
run_codeowners(
"invalid_project",
&["validate"],
false,
OutputStream::Stdout,
predicate::eq(indoc! {"
The following changes are required (- current, + expected):
+# STOP! - DO NOT EDIT THIS FILE MANUALLY
+# This file was automatically generated by \"bin/codeownership validate\".
+#
+# CODEOWNERS is used for GitHub to suggest code/file owners to various GitHub
+# teams. This is useful when developers create Pull Requests since the
+# code/file owner is notified. Reference GitHub docs for more details:
+# https://help.github.com/en/articles/about-code-owners
+
+# Annotations at the top of file
+/gems/payroll_calculator/calculator.rb @PaymentTeam
+/ruby/app/models/bank_account.rb @PaymentTeam
+/ruby/app/models/payroll.rb @PayrollTeam
+/ruby/app/services/multi_owned.rb @PaymentTeam
+
+# Team-specific owned globs
+/ruby/app/payments/**/* @PaymentTeam
+
+# Owner in .codeowner
+/ruby/app/services/**/** @PayrollTeam
+
+# Owner metadata key in package.yml
+/ruby/packages/payroll_flow/**/** @PayrollTeam
+
+# Team YML ownership
+/config/teams/payments.yml @PaymentTeam
+/config/teams/payroll.yml @PayrollTeam
+
+# Team owned gems
+/gems/payroll_calculator/**/** @PayrollTeam
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>> {
run_codeowners(
"invalid_project",
&["for-file", "ruby/app/models/blockchain.rb"],
true,
OutputStream::Stdout,
predicate::eq(indoc! {"
Team: Unowned
Github Team: Unowned
Team YML:
Description:
"}),
)?;
Ok(())
}
#[test]
fn test_for_file_json() -> Result<(), Box<dyn Error>> {
run_codeowners(
"invalid_project",
&["for-file", "ruby/app/models/blockchain.rb", "--json"],
true,
OutputStream::Stdout,
predicate::eq(indoc! {r#"
{
"team_name": "Unowned",
"github_team": "Unowned",
"team_yml": "",
"description": []
}
"#}),
)?;
Ok(())
}
#[test]
fn test_for_file_multiple_owners() -> Result<(), Box<dyn Error>> {
run_codeowners(
"invalid_project",
&["for-file", "ruby/app/services/multi_owned.rb"],
false,
OutputStream::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(())
}
#[test]
fn test_for_file_multiple_owners_json() -> Result<(), Box<dyn Error>> {
run_codeowners(
"invalid_project",
&["for-file", "ruby/app/services/multi_owned.rb", "--json"],
false,
OutputStream::Stdout,
predicate::eq(indoc! {r#"
{
"validation_errors": [
"Error: file is owned by multiple teams!",
"\nTeam: Payments\nGithub Team: @PaymentTeam\nTeam YML: config/teams/payments.yml\nDescription:\n- Owner annotation at the top of the file",
"\nTeam: Payroll\nGithub Team: @PayrollTeam\nTeam YML: config/teams/payroll.yml\nDescription:\n- Owner specified in `ruby/app/services/.codeowner`"
]
}
"#}),
)?;
Ok(())
}
#[test]
fn test_for_file_nonexistent_json() -> Result<(), Box<dyn Error>> {
run_codeowners(
"invalid_project",
&["for-file", "nonexistent/file.rb", "--json"],
true,
OutputStream::Stdout,
predicate::eq(indoc! {r#"
{
"team_name": "Unowned",
"github_team": "Unowned",
"team_yml": "",
"description": []
}
"#}),
)?;
Ok(())
}