MCPcopy Create free account
hub / github.com/alecthomas/kong / TestMapDecoderHelpfulErrorMsg

Function TestMapDecoderHelpfulErrorMsg

kong_test.go:2692–2740  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2690}
2691
2692func TestMapDecoderHelpfulErrorMsg(t *testing.T) {
2693 tests := []struct {
2694 name string
2695 cli any
2696 args []string
2697 expected string
2698 }{
2699 {
2700 "DefaultRune",
2701 &struct {
2702 Stuff map[string]int
2703 }{},
2704 []string{"--stuff"},
2705 `--stuff: missing value, expecting "<key>=<value>;..."`,
2706 },
2707 {
2708 "SpecifiedRune",
2709 &struct {
2710 Stuff map[string]int `mapsep:";"`
2711 }{},
2712 []string{"--stuff"},
2713 `--stuff: missing value, expecting "<key>=<value>;..."`,
2714 },
2715 {
2716 "SpaceRune",
2717 &struct {
2718 Stuff map[string]int `mapsep:" "`
2719 }{},
2720 []string{"--stuff"},
2721 `--stuff: missing value, expecting "<key>=<value> ..."`,
2722 },
2723 {
2724 "OtherRune",
2725 &struct {
2726 Stuff map[string]int `mapsep:","`
2727 }{},
2728 []string{"--stuff"},
2729 `--stuff: missing value, expecting "<key>=<value>,..."`,
2730 },
2731 }
2732 for _, test := range tests {
2733 test := test
2734 t.Run(test.name, func(t *testing.T) {
2735 p := mustNew(t, test.cli)
2736 _, err := p.Parse(test.args)
2737 assert.EqualError(t, err, test.expected)
2738 })
2739 }
2740}
2741
2742func TestDuplicateName(t *testing.T) {
2743 var cli struct {

Callers

nothing calls this directly

Calls 3

mustNewFunction · 0.85
RunMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected