-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5424 from jsternberg/wsl-socket-path
command: check for wsl mount path on windows
- Loading branch information
Showing
2 changed files
with
141 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package command | ||
|
||
import ( | ||
"net/url" | ||
"testing" | ||
"testing/fstest" | ||
|
||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestWslSocketPath(t *testing.T) { | ||
u, err := url.Parse("unix:////./c:/my/file/path") | ||
assert.NilError(t, err) | ||
|
||
// Ensure host is empty. | ||
assert.Equal(t, u.Host, "") | ||
|
||
// Use a filesystem where the WSL path exists. | ||
fs := fstest.MapFS{ | ||
"mnt/c/my/file/path": {}, | ||
} | ||
assert.Equal(t, wslSocketPath(u.Path, fs), "/mnt/c/my/file/path") | ||
|
||
// Use a filesystem where the WSL path doesn't exist. | ||
fs = fstest.MapFS{ | ||
"my/file/path": {}, | ||
} | ||
assert.Equal(t, wslSocketPath(u.Path, fs), "") | ||
} |