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

Function TestArgsPropertySource_OptionValues

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

Source from the content-addressed store, hash-verified

405}
406
407func TestArgsPropertySource_OptionValues(t *testing.T) {
408 testCases := []struct {
409 name string
410 args []string
411 propName string
412 wantValues []string
413 }{
414 {
415 name: "option does not exist",
416 propName: "argKey4",
417 args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"},
418 wantValues: nil,
419 },
420 {
421 name: "option with one value",
422 propName: "argKey3",
423 args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val"},
424 wantValues: []string{"arg3Val"},
425 },
426 {
427 name: "option with multiple values",
428 propName: "argKey3",
429 args: []string{"argKey1", "-argKey2", "--argKey3=arg3Val", "--argKey3=arg3AnotherVal"},
430 wantValues: []string{"arg3Val", "arg3AnotherVal"},
431 },
432 }
433
434 for _, tc := range testCases {
435 t.Run(tc.name, func(t *testing.T) {
436 // given
437 args, err := ParseArgs(tc.args)
438 require.NoError(t, err)
439
440 argsPropSource := NewArgsPropertySource(args)
441
442 // when
443 values := argsPropSource.OptionValues(tc.propName)
444
445 // then
446 assert.Equal(t, tc.wantValues, values)
447 })
448 }
449}
450
451func TestArgsPropertySource_NonOptionArgs(t *testing.T) {
452 // given

Callers

nothing calls this directly

Calls 4

OptionValuesMethod · 0.95
ParseArgsFunction · 0.85
NewArgsPropertySourceFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected