mirror of https://github.com/coder/coder.git
feat(cli): add error message for bad login URL (#4042)
This commit is contained in:
parent
62d97b18f4
commit
22e49c4316
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue