Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 92 additions & 1 deletion pkg/remote/connparse/connparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,98 @@ func TestParseURI_WSHLocalShorthand(t *testing.T) {
if c.GetFullURI() != expected {
t.Fatalf("expected full URI to be %q, got %q", expected, c.GetFullURI())
}
}

func TestParseURI_WSHWSL(t *testing.T) {
t.Parallel()
cstr := "wsh://wsl://Ubuntu/path/to/file"

testUri := func() {
c, err := connparse.ParseURI(cstr)
if err != nil {
t.Fatalf("failed to parse URI: %v", err)
}
expected := "/path/to/file"
if c.Path != expected {
t.Fatalf("expected path to be %q, got %q", expected, c.Path)
}
expected = "wsl://Ubuntu"
if c.Host != expected {
t.Fatalf("expected host to be %q, got %q", expected, c.Host)
}
expected = "wsh"
if c.Scheme != expected {
t.Fatalf("expected scheme to be %q, got %q", expected, c.Scheme)
}
expected = "wsh://wsl://Ubuntu/path/to/file"
if expected != c.GetFullURI() {
t.Fatalf("expected full URI to be %q, got %q", expected, c.GetFullURI())
}
}
t.Log("Testing with scheme")
testUri()

t.Log("Testing without scheme")
cstr = "//wsl://Ubuntu/path/to/file"
testUri()
}

func TestParseUri_LocalWindowsAbsPath(t *testing.T) {
t.Parallel()
cstr := "wsh://local/C:\\path\\to\\file"

testAbsPath := func() {
c, err := connparse.ParseURI(cstr)
if err != nil {
t.Fatalf("failed to parse URI: %v", err)
}
expected := "C:\\path\\to\\file"
if c.Path != expected {
t.Fatalf("expected path to be %q, got %q", expected, c.Path)
}
expected = "local"
if c.Host != expected {
t.Fatalf("expected host to be %q, got %q", expected, c.Host)
}
expected = "wsh"
if c.Scheme != expected {
t.Fatalf("expected scheme to be %q, got %q", expected, c.Scheme)
}
expected = "wsh://local/C:\\path\\to\\file"
if c.GetFullURI() != expected {
t.Fatalf("expected full URI to be %q, got %q", expected, c.GetFullURI())
}
}

t.Log("Testing with scheme")
testAbsPath()
t.Log("Testing without scheme")
cstr = "//local/C:\\path\\to\\file"
testAbsPath()
}

func TestParseURI_LocalWindowsRelativeShorthand(t *testing.T) {
cstr := "/~\\path\\to\\file"
c, err := connparse.ParseURI(cstr)
if err != nil {
t.Fatalf("failed to parse URI: %v", err)
}
expected := "~\\path\\to\\file"
if c.Path != expected {
t.Fatalf("expected path to be %q, got %q", expected, c.Path)
}
expected = "local"
if c.Host != expected {
t.Fatalf("expected host to be %q, got %q", expected, c.Host)
}
expected = "wsh"
if c.Scheme != expected {
t.Fatalf("expected scheme to be %q, got %q", expected, c.Scheme)
}
expected = "wsh://local/~\\path\\to\\file"
if c.GetFullURI() != expected {
t.Fatalf("expected full URI to be %q, got %q", expected, c.GetFullURI())
}
}

func TestParseURI_BasicS3(t *testing.T) {
Expand All @@ -239,7 +330,7 @@ func TestParseURI_BasicS3(t *testing.T) {
if err != nil {
t.Fatalf("failed to parse URI: %v", err)
}
expected := "/path/to/file"
expected := "path/to/file"
if c.Path != expected {
t.Fatalf("expected path to be %q, got %q", expected, c.Path)
}
Expand Down
Loading