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

Function TestMapDecoderHelpfulErrorMsg

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

Source from the content-addressed store, hash-verified

2251}
2252
2253func TestMapDecoderHelpfulErrorMsg(t *testing.T) {
2254 tests := []struct {
2255 name string
2256 cli any
2257 args []string
2258 expected string
2259 }{
2260 {
2261 "DefaultRune",
2262 &struct {
2263 Stuff map[string]int
2264 }{},
2265 []string{"--stuff"},
2266 `--stuff: missing value, expecting "<key>=<value>;..."`,
2267 },
2268 {
2269 "SpecifiedRune",
2270 &struct {
2271 Stuff map[string]int `mapsep:";"`
2272 }{},
2273 []string{"--stuff"},
2274 `--stuff: missing value, expecting "<key>=<value>;..."`,
2275 },
2276 {
2277 "SpaceRune",
2278 &struct {
2279 Stuff map[string]int `mapsep:" "`
2280 }{},
2281 []string{"--stuff"},
2282 `--stuff: missing value, expecting "<key>=<value> ..."`,
2283 },
2284 {
2285 "OtherRune",
2286 &struct {
2287 Stuff map[string]int `mapsep:","`
2288 }{},
2289 []string{"--stuff"},
2290 `--stuff: missing value, expecting "<key>=<value>,..."`,
2291 },
2292 }
2293 for _, test := range tests {
2294 test := test
2295 t.Run(test.name, func(t *testing.T) {
2296 p := mustNew(t, test.cli)
2297 _, err := p.Parse(test.args)
2298 assert.EqualError(t, err, test.expected)
2299 })
2300 }
2301}
2302
2303func TestDuplicateName(t *testing.T) {
2304 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