feat(cli): add error message for bad login URL (#4042)

This commit is contained in:
Joe Previte
2022-09-14 20:15:47 +00:00
committed by GitHub
parent 62d97b18f4
commit 22e49c4316
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ func login() *cobra.Command {
hasInitialUser, err := client.HasFirstUser(cmd.Context())
if err != nil {
return xerrors.Errorf("has initial user: %w", err)
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)
}
if !hasInitialUser {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Your Coder deployment hasn't been set up!\n")
+10
View File
@@ -2,6 +2,7 @@ package cli_test
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
@@ -23,6 +24,15 @@ func TestLogin(t *testing.T) {
require.Error(t, err)
})
t.Run("InitialUserBadLoginURL", func(t *testing.T) {
t.Parallel()
badLoginURL := "https://fcca2077f06e68aaf9"
root, _ := clitest.New(t, "login", badLoginURL)
err := root.Execute()
errMsg := fmt.Sprintf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser?", badLoginURL)
require.ErrorContains(t, err, errMsg)
})
t.Run("InitialUserTTY", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)