MCPcopy
hub / github.com/ossf/scorecard / TestReleaseAndDevBranchProtected

Function TestReleaseAndDevBranchProtected

checks/branch_protection_test.go:55–437  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestReleaseAndDevBranchProtected(t *testing.T) {
56 t.Parallel()
57
58 rel1 := "release/v.1"
59 sha := "8fb3cb86082b17144a80402f5367ae65f06083bd"
60 main := "main"
61 trueVal := true
62 falseVal := false
63 var zeroVal int32
64
65 var oneVal int32 = 1
66
67 tests := []struct {
68 name string
69 defaultBranch string
70 branches []*clients.BranchRef
71 releases []string
72 repoFiles []string
73 expected scut.TestReturn
74 nonadmin bool
75 }{
76 {
77 name: "Nil release and main branch names",
78 expected: scut.TestReturn{
79 Error: nil,
80 Score: checker.InconclusiveResultScore,
81 NumberOfWarn: 0,
82 NumberOfInfo: 0,
83 NumberOfDebug: 0,
84 },
85 defaultBranch: main,
86 branches: []*clients.BranchRef{
87 {
88 Protected: &trueVal,
89 BranchProtectionRule: clients.BranchProtectionRule{
90 CheckRules: clients.StatusChecksRule{
91 RequiresStatusChecks: &trueVal,
92 UpToDateBeforeMerge: &trueVal,
93 Contexts: []string{"foo"},
94 },
95 PullRequestRule: clients.PullRequestRule{
96 Required: &trueVal,
97 DismissStaleReviews: &trueVal,
98 RequireCodeOwnerReviews: &trueVal,
99 RequiredApprovingReviewCount: &oneVal,
100 },
101 EnforceAdmins: &trueVal,
102 RequireLinearHistory: &trueVal,
103 AllowForcePushes: &falseVal,
104 AllowDeletions: &falseVal,
105 },
106 },
107 {
108 Protected: &trueVal,
109 BranchProtectionRule: clients.BranchProtectionRule{
110 CheckRules: clients.StatusChecksRule{
111 RequiresStatusChecks: &trueVal,
112 UpToDateBeforeMerge: &falseVal,

Callers

nothing calls this directly

Calls 8

EXPECTMethod · 0.95
getBranchFunction · 0.85
BranchProtectionFunction · 0.70
RunMethod · 0.65
GetDefaultBranchMethod · 0.65
ListReleasesMethod · 0.65
GetBranchMethod · 0.65
ListFilesMethod · 0.65

Tested by

no test coverage detected