debug failing tests

Signed-off-by: Adam Korczynski <adam@adalogics.com>
This commit is contained in:
Adam Korczynski 2024-02-05 14:23:37 +00:00 committed by AdamKorcz
parent 2d26086d74
commit 00acf66ea6
4 changed files with 17 additions and 11 deletions

View File

@ -174,7 +174,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
Error: nil,
Score: 4,
NumberOfWarn: 9,
NumberOfInfo: 11,
NumberOfInfo: 12,
NumberOfDebug: 0,
},
defaultBranch: main,
@ -232,7 +232,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
Error: nil,
Score: 8,
NumberOfWarn: 4,
NumberOfInfo: 16,
NumberOfInfo: 18,
NumberOfDebug: 0,
},
defaultBranch: main,

View File

@ -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)
}

View File

@ -521,7 +521,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
@ -1227,7 +1228,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
@ -1315,7 +1317,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
@ -1403,7 +1406,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main": 1,
"main": 1,
"CodeownersFiles": 2,
},
},
{
@ -1481,7 +1485,8 @@ func TestBranchProtection(t *testing.T) {
Probe: "requiresCodeOwnersReview",
Outcome: finding.OutcomePositive,
Values: map[string]int{
"main2": 1,
"main2": 1,
"CodeownersFiles": 2,
},
},
{

View File

@ -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