Skip to content

Commit 90ad6fd

Browse files
committed
Revert "chore(cli): fix test flake in TestExpMcpServer"
This reverts commit 12405ae.
1 parent a90ccc9 commit 90ad6fd

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

cli/exp_mcp_test.go

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,35 +133,29 @@ func TestExpMcpServer(t *testing.T) {
133133
require.Equal(t, 1.0, initializeResponse["id"])
134134
require.NotNil(t, initializeResponse["result"])
135135
})
136+
}
136137

137-
t.Run("NoCredentials", func(t *testing.T) {
138-
t.Parallel()
139-
140-
ctx := testutil.Context(t, testutil.WaitShort)
141-
cancelCtx, cancel := context.WithCancel(ctx)
142-
t.Cleanup(cancel)
138+
func TestExpMcpServerNoCredentials(t *testing.T) {
139+
// Ensure that no credentials are set from the environment.
140+
t.Setenv("CODER_AGENT_TOKEN", "")
141+
t.Setenv("CODER_AGENT_TOKEN_FILE", "")
142+
t.Setenv("CODER_SESSION_TOKEN", "")
143143

144-
client := coderdtest.New(t, nil)
145-
inv, root := clitest.New(t, "exp", "mcp", "server")
146-
inv = inv.WithContext(cancelCtx)
144+
ctx := testutil.Context(t, testutil.WaitShort)
145+
cancelCtx, cancel := context.WithCancel(ctx)
146+
t.Cleanup(cancel)
147147

148-
pty := ptytest.New(t)
149-
inv.Stdin = pty.Input()
150-
inv.Stdout = pty.Output()
151-
inv.Stderr = pty.Output()
152-
clitest.SetupConfig(t, client, root)
148+
client := coderdtest.New(t, nil)
149+
inv, root := clitest.New(t, "exp", "mcp", "server")
150+
inv = inv.WithContext(cancelCtx)
153151

154-
cmdDone := make(chan struct{})
155-
go func() {
156-
defer close(cmdDone)
157-
err := inv.Run()
158-
assert.NoError(t, err)
159-
}()
152+
pty := ptytest.New(t)
153+
inv.Stdin = pty.Input()
154+
inv.Stdout = pty.Output()
155+
clitest.SetupConfig(t, client, root)
160156

161-
pty.ExpectRegexMatch(`(?is)Authentication\s+:\s+None`)
162-
cancel()
163-
<-cmdDone
164-
})
157+
err := inv.Run()
158+
assert.ErrorContains(t, err, "are not logged in")
165159
}
166160

167161
//nolint:tparallel,paralleltest

0 commit comments

Comments
 (0)