Skip to content

Commit

Permalink
debug failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <adam@adalogics.com>
  • Loading branch information
AdamKorcz committed Feb 24, 2024
1 parent 2d26086 commit 00acf66
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions checks/branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
Error: nil,
Score: 4,
NumberOfWarn: 9,
NumberOfInfo: 11,
NumberOfInfo: 12,
NumberOfDebug: 0,
},
defaultBranch: main,
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
Error: nil,
Score: 8,
NumberOfWarn: 4,
NumberOfInfo: 16,
NumberOfInfo: 18,
NumberOfDebug: 0,
},
defaultBranch: main,
Expand Down
6 changes: 5 additions & 1 deletion checks/evaluation/branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,11 @@ func codeownerBranchProtection(f *finding.Finding, doLogging bool, dl checker.De
var score, max int
if f.Outcome == finding.OutcomePositive {
info(dl, doLogging, f.Message)
score++
if f.Values["CodeownersFiles"] == 0 {
warn(dl, doLogging, "codeowners branch protection is being ignored - but no codeowners file found in repo")
} else {
score++
}
} else {
warn(dl, doLogging, f.Message)
}
Expand Down
15 changes: 10 additions & 5 deletions checks/evaluation/branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
Expand Down Expand Up @@ -1227,7 +1228,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
Expand Down Expand Up @@ -1315,7 +1317,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
Expand Down Expand Up @@ -1403,7 +1406,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
Expand Down Expand Up @@ -1481,7 +1485,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main2": 1,
"main2": 1,
"CodeownersFiles": 2,
},
},
{
Expand Down
3 changes: 0 additions & 3 deletions probes/requiresCodeOwnersReview/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ func Run(raw *checker.RawResults) ([]finding.Finding, string, error) {
case !*reqOwnerReviews:
text = fmt.Sprintf("codeowners review is not required on branch '%s'", *branch.Name)
outcome = finding.OutcomeNegative
case len(r.CodeownersFiles) == 0:
text = "codeowners review is required - but no codeowners file found in repo"
outcome = finding.OutcomeNegative
default:
text = fmt.Sprintf("codeowner review is required on branch '%s'", *branch.Name)
outcome = finding.OutcomePositive
Expand Down

0 comments on commit 00acf66

Please sign in to comment.