Skip to content

Commit d3d5e1e

Browse files
committed
update tests that were failing due to login error message changes
Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent 730b5dd commit d3d5e1e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

cli/logout_test.go

+7-2
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"
@@ -90,9 +91,13 @@ func TestLogout(t *testing.T) {
9091
logout.Stdout = pty.Output()
9192

9293
go func() {
94+
executable, err := os.Executable()
95+
require.NoError(t, err)
96+
require.NotEqual(t, "", executable)
97+
9398
defer close(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+
require.Contains(t, err.Error(), fmt.Sprintf("Try logging in using '%s login <url>'.", executable))
96101
}()
97102

98103
<-logoutChan

cli/userlist_test.go

+7-2
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)