Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit578b9ff

Browse files
authored
fix: enrich thenotLoggedInMessage error message with the full path to the coder (#17715)
---------Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent15bd7a3 commit578b9ff

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

‎cli/logout_test.go

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

33
import (
4+
"fmt"
45
"os"
56
"runtime"
67
"testing"
@@ -89,10 +90,14 @@ func TestLogout(t *testing.T) {
8990
logout.Stdin=pty.Input()
9091
logout.Stdout=pty.Output()
9192

93+
executable,err:=os.Executable()
94+
require.NoError(t,err)
95+
require.NotEqual(t,"",executable)
96+
9297
gofunc() {
9398
deferclose(logoutChan)
94-
err:=logout.Run()
95-
assert.ErrorContains(t,err,"You are not logged in.Try logging in using 'coder login <url>'.")
99+
err=logout.Run()
100+
assert.Contains(t,err.Error(),fmt.Sprintf("Try logging in using '%s login <url>'.",executable))
96101
}()
97102

98103
<-logoutChan

‎cli/root.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const (
7272
varDisableDirect="disable-direct-connections"
7373
varDisableNetworkTelemetry="disable-network-telemetry"
7474

75-
notLoggedInMessage="You are not logged in. Try logging in using 'coder login <url>'."
75+
notLoggedInMessage="You are not logged in. Try logging in using '%s login <url>'."
7676

7777
envNoVersionCheck="CODER_NO_VERSION_WARNING"
7878
envNoFeatureWarning="CODER_NO_FEATURE_WARNING"
@@ -534,7 +534,11 @@ func (r *RootCmd) InitClient(client *codersdk.Client) serpent.MiddlewareFunc {
534534
rawURL,err:=conf.URL().Read()
535535
// If the configuration files are absent, the user is logged out
536536
ifos.IsNotExist(err) {
537-
returnxerrors.New(notLoggedInMessage)
537+
binPath,err:=os.Executable()
538+
iferr!=nil {
539+
binPath="coder"
540+
}
541+
returnxerrors.Errorf(notLoggedInMessage,binPath)
538542
}
539543
iferr!=nil {
540544
returnerr

‎cli/userlist_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"bytes"
55
"context"
66
"encoding/json"
7+
"fmt"
8+
"os"
79
"testing"
810

911
"github.com/stretchr/testify/assert"
@@ -69,9 +71,12 @@ func TestUserList(t *testing.T) {
6971
t.Run("NoURLFileErrorHasHelperText",func(t*testing.T) {
7072
t.Parallel()
7173

74+
executable,err:=os.Executable()
75+
require.NoError(t,err)
76+
7277
inv,_:=clitest.New(t,"users","list")
73-
err:=inv.Run()
74-
require.Contains(t,err.Error(),"Try logging in using 'coder login <url>'.")
78+
err=inv.Run()
79+
require.Contains(t,err.Error(),fmt.Sprintf("Try logging in using '%s login <url>'.",executable))
7580
})
7681
t.Run("SessionAuthErrorHasHelperText",func(t*testing.T) {
7782
t.Parallel()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp