MCPcopy Create free account
hub / github.com/codnect/procyon / TestArgs_OptionValues

Function TestArgs_OptionValues

runtime/argument_test.go:144–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

142}
143
144func TestArgs_OptionValues(t *testing.T) {
145 testCases := []struct {
146 name string
147 args []string
148 optionName string
149 wantValues []string
150 }{
151 {
152 name: "option does not exist",
153 optionName: "argKey4",
154 args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"},
155 wantValues: nil,
156 },
157 {
158 name: "option with one value",
159 optionName: "argKey3",
160 args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"},
161 wantValues: []string{"arg3Val"},
162 },
163 {
164 name: "option with multiple values",
165 optionName: "argKey3",
166 args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val", "--argKey3=arg3AnotherVal"},
167 wantValues: []string{"arg3Val", "arg3AnotherVal"},
168 },
169 }
170
171 for _, tc := range testCases {
172 t.Run(tc.name, func(t *testing.T) {
173 // given
174 args, err := ParseArgs(tc.args)
175 require.NoError(t, err)
176
177 // when
178 values := args.OptionValues(tc.optionName)
179
180 // then
181 assert.Equal(t, tc.wantValues, values)
182 })
183 }
184}
185
186func TestArgs_NonOptionArgs(t *testing.T) {
187 // given

Callers

nothing calls this directly

Calls 3

ParseArgsFunction · 0.85
RunMethod · 0.65
OptionValuesMethod · 0.45

Tested by

no test coverage detected