Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup branch protection tests #3904

Closed
spencerschrock opened this issue Feb 27, 2024 · 0 comments · Fixed by #3932
Closed

cleanup branch protection tests #3904

spencerschrock opened this issue Feb 27, 2024 · 0 comments · Fixed by #3932

Comments

@spencerschrock
Copy link
Contributor

From #3759 (comment):

can we just create a pre-defined var (for the probes that don't have other values, like the number of reviewers) so we can cut down on the lines and increase readability?

mainBranchValues := map[string]int{
	"main": 1,
},

And then the tests can just reference:

Probe:   "blocksForcePushOnBranches",
Outcome: finding.OutcomePositive,
Values: mainBranchValues

Or even just a helper func to make a finding based on name + outcome?

func testFinding(probe string, outcome finding.Outcome) finding.Outcome {
	return finding.Finding{
		Probe: probe,
		Outcome: outcome,
		Values: map[string]int{
			"main": 1,
		},
	}
}

And then we cut down on the toil/lines?

findings: []finding.Finding{
	testFinding("blocksDeleteOnBranches", finding.OutcomePositive),
	testFinding("blocksForcePushOnBranches", finding.OutcomePositive),
	// and so on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant