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

Function TestWindowsFileMapper

mapper_windows_test.go:28–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestWindowsFileMapper(t *testing.T) {
29 type CLI struct {
30 File *os.File `arg:""`
31 }
32 var cli CLI
33 p := mustNew(t, &cli)
34 _, err := p.Parse([]string{"testdata\\file.txt"})
35 assert.NoError(t, err)
36 assert.NotZero(t, cli.File, "File should not be nil")
37 _ = cli.File.Close()
38 _, err = p.Parse([]string{"testdata\\missing.txt"})
39 assert.Error(t, err)
40 assert.Contains(t, err.Error(), "missing.txt:")
41 assert.IsError(t, err, os.ErrNotExist)
42 _, err = p.Parse([]string{"-"})
43 assert.NoError(t, err)
44 assert.Equal(t, os.Stdin, cli.File)
45}

Callers

nothing calls this directly

Calls 3

mustNewFunction · 0.85
ParseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected