MCPcopy Index your code
hub / github.com/docker/cli / TestWslSocketPath

Function TestWslSocketPath

cli/command/telemetry_docker_test.go:12–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestWslSocketPath(t *testing.T) {
13 testCases := []struct {
14 doc string
15 fs fs.FS
16 url string
17 expected string
18 }{
19 {
20 doc: "filesystem where WSL path does not exist",
21 fs: fstest.MapFS{
22 "my/file/path": {},
23 },
24 url: "unix:////./c:/my/file/path",
25 expected: "",
26 },
27 {
28 doc: "filesystem where WSL path exists",
29 fs: fstest.MapFS{
30 "mnt/c/my/file/path": {},
31 },
32 url: "unix:////./c:/my/file/path",
33 expected: "/mnt/c/my/file/path",
34 },
35 {
36 doc: "filesystem where WSL path exists uppercase URL",
37 fs: fstest.MapFS{
38 "mnt/c/my/file/path": {},
39 },
40 url: "unix:////./C:/my/file/path",
41 expected: "/mnt/c/my/file/path",
42 },
43 }
44
45 for _, tc := range testCases {
46 t.Run(tc.doc, func(t *testing.T) {
47 u, err := url.Parse(tc.url)
48 assert.NilError(t, err)
49 // Ensure host is empty.
50 assert.Equal(t, u.Host, "")
51
52 result := wslSocketPath(u.Path, tc.fs)
53
54 assert.Equal(t, result, tc.expected)
55 })
56 }
57}

Callers

nothing calls this directly

Calls 1

wslSocketPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…