Skip to content

Commit 0782811

Browse files
committed
feat(cli): add error message for bad login URL
1 parent a01ab27 commit 0782811

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cli/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func login() *cobra.Command {
8383

8484
hasInitialUser, err := client.HasFirstUser(cmd.Context())
8585
if err != nil {
86-
return xerrors.Errorf("has initial user: %w", err)
86+
return xerrors.Errorf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser? Error - has initial user: %w", serverURL.String(), err)
8787
}
8888
if !hasInitialUser {
8989
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Your Coder deployment hasn't been set up!\n")

cli/login_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli_test
22

33
import (
44
"context"
5+
"fmt"
56
"testing"
67

78
"github.com/stretchr/testify/assert"
@@ -23,6 +24,15 @@ func TestLogin(t *testing.T) {
2324
require.Error(t, err)
2425
})
2526

27+
t.Run("InitialUserBadLoginURL", func(t *testing.T) {
28+
t.Parallel()
29+
badLoginURL := "https://fcca2077f06e68aaf9"
30+
root, _ := clitest.New(t, "login", badLoginURL)
31+
err := root.Execute()
32+
errMsg := fmt.Sprintf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser?", badLoginURL)
33+
require.ErrorContains(t, err, errMsg)
34+
})
35+
2636
t.Run("InitialUserTTY", func(t *testing.T) {
2737
t.Parallel()
2838
client := coderdtest.New(t, nil)

0 commit comments

Comments
 (0)