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

Function TestDurationMapperJSONResolver

mapper_test.go:129–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

127}
128
129func TestDurationMapperJSONResolver(t *testing.T) {
130 var cli struct {
131 Flag time.Duration
132 }
133 resolver, err := kong.JSON(strings.NewReader(`{"flag": 5000000000}`))
134 assert.NoError(t, err)
135 k := mustNew(t, &cli, kong.Resolvers(resolver))
136 _, err = k.Parse(nil)
137 assert.NoError(t, err)
138 assert.Equal(t, time.Second*5, cli.Flag)
139}
140
141func TestSplitEscaped(t *testing.T) {
142 assert.Equal(t, []string{"a", "b"}, kong.SplitEscaped("a,b", ','))

Callers

nothing calls this directly

Calls 4

JSONFunction · 0.92
ResolversFunction · 0.92
mustNewFunction · 0.85
ParseMethod · 0.45

Tested by

no test coverage detected