-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
codespace code
command under WSL (cli#4747)
The `codespace code` command used the `skratchdot/open-golang` library to open `vscode://` URLs, which uses `xdg-open` for Linux under the hood, which isn't available under WSL. This switches over to using the `cli/browser` package which has explicit support for WSL by invoking `wslview` when found.
- Loading branch information
Showing
4 changed files
with
61 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
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,50 @@ | ||
package codespace | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cli/cli/v2/pkg/cmdutil" | ||
) | ||
|
||
func TestApp_VSCode(t *testing.T) { | ||
type args struct { | ||
codespaceName string | ||
useInsiders bool | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
wantURL string | ||
}{ | ||
{ | ||
name: "open VS Code", | ||
args: args{ | ||
codespaceName: "monalisa-cli-cli-abcdef", | ||
useInsiders: false, | ||
}, | ||
wantErr: false, | ||
wantURL: "vscode://github.codespaces/connect?name=monalisa-cli-cli-abcdef", | ||
}, | ||
{ | ||
name: "open VS Code Insiders", | ||
args: args{ | ||
codespaceName: "monalisa-cli-cli-abcdef", | ||
useInsiders: true, | ||
}, | ||
wantErr: false, | ||
wantURL: "vscode-insiders://github.codespaces/connect?name=monalisa-cli-cli-abcdef", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
b := &cmdutil.TestBrowser{} | ||
a := &App{} | ||
if err := a.VSCode(context.Background(), b, tt.args.codespaceName, tt.args.useInsiders); (err != nil) != tt.wantErr { | ||
t.Errorf("App.VSCode() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
b.Verify(t, tt.wantURL) | ||
}) | ||
} | ||
} |