(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…