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

Function TestOptions_AddFlags_ChecksToRun

options/flags_test.go:121–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestOptions_AddFlags_ChecksToRun(t *testing.T) {
122 t.Parallel()
123 tests := []struct {
124 name string
125 opts *Options
126 expected []string
127 }{
128 {
129 name: "custom options",
130 opts: &Options{
131 ChecksToRun: []string{"check1", "check2"},
132 },
133 expected: []string{"check1", "check2"},
134 },
135 }
136
137 for _, tt := range tests {
138 t.Run(tt.name, func(t *testing.T) {
139 t.Parallel()
140 e := []string{}
141 cmd := &cobra.Command{}
142 tt.opts.AddFlags(cmd)
143 for _, f := range strings.Split(cmd.Flag(FlagChecks).Value.String(), ",") {
144 f = strings.TrimPrefix(f, "[")
145 f = strings.TrimSuffix(f, "]")
146 e = append(e, f)
147 }
148 if !cmp.Equal(e, tt.expected) {
149 t.Errorf("expected FlagChecks to be %q, but got %q", tt.expected, e)
150 }
151 })
152 }
153}
154
155func TestOptions_AddFlags_Format(t *testing.T) {
156 t.Parallel()

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
AddFlagsMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected