-
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.
command: check for wsl mount path on windows
This checks for the equivalent WSL mount path on windows. WSL will mount the windows drives at `/mnt/c` (or whichever drive is being used). This is done by parsing a UNC path with forward slashes from the unix socket URL. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com> (cherry picked from commit 38c3fef) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- Loading branch information
1 parent
c85c3df
commit b48720e
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), "") | ||
} |