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

Function TestExistingFileMapperDefaultMissing

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

Source from the content-addressed store, hash-verified

627}
628
629func TestExistingFileMapperDefaultMissing(t *testing.T) {
630 type CLI struct {
631 File string `type:"existingfile" default:"testdata/missing.txt"`
632 }
633 var cli CLI
634 p := mustNew(t, &cli)
635 file := filepath.Join("testdata", "file.txt")
636 _, err := p.Parse([]string{"--file", file})
637 assert.NoError(t, err)
638 assert.NotZero(t, cli.File)
639 assert.Contains(t, cli.File, file)
640 p = mustNew(t, &cli)
641 _, err = p.Parse([]string{})
642 assert.Error(t, err)
643 assert.Contains(t, err.Error(), "missing.txt:")
644 assert.IsError(t, err, os.ErrNotExist)
645}
646
647func TestExistingFileMapperDefaultMissingCmds(t *testing.T) {
648 type CLI struct {

Callers

nothing calls this directly

Calls 3

mustNewFunction · 0.85
ParseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected