mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
chore(cli): fix test flake in TestExpMcpServer (#17772)
Test was failing inside a Coder workspace.
This commit is contained in:
@ -133,26 +133,29 @@ func TestExpMcpServer(t *testing.T) {
|
|||||||
require.Equal(t, 1.0, initializeResponse["id"])
|
require.Equal(t, 1.0, initializeResponse["id"])
|
||||||
require.NotNil(t, initializeResponse["result"])
|
require.NotNil(t, initializeResponse["result"])
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
t.Run("NoCredentials", func(t *testing.T) {
|
func TestExpMcpServerNoCredentials(t *testing.T) {
|
||||||
t.Parallel()
|
// Ensure that no credentials are set from the environment.
|
||||||
|
t.Setenv("CODER_AGENT_TOKEN", "")
|
||||||
|
t.Setenv("CODER_AGENT_TOKEN_FILE", "")
|
||||||
|
t.Setenv("CODER_SESSION_TOKEN", "")
|
||||||
|
|
||||||
ctx := testutil.Context(t, testutil.WaitShort)
|
ctx := testutil.Context(t, testutil.WaitShort)
|
||||||
cancelCtx, cancel := context.WithCancel(ctx)
|
cancelCtx, cancel := context.WithCancel(ctx)
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
||||||
client := coderdtest.New(t, nil)
|
client := coderdtest.New(t, nil)
|
||||||
inv, root := clitest.New(t, "exp", "mcp", "server")
|
inv, root := clitest.New(t, "exp", "mcp", "server")
|
||||||
inv = inv.WithContext(cancelCtx)
|
inv = inv.WithContext(cancelCtx)
|
||||||
|
|
||||||
pty := ptytest.New(t)
|
pty := ptytest.New(t)
|
||||||
inv.Stdin = pty.Input()
|
inv.Stdin = pty.Input()
|
||||||
inv.Stdout = pty.Output()
|
inv.Stdout = pty.Output()
|
||||||
clitest.SetupConfig(t, client, root)
|
clitest.SetupConfig(t, client, root)
|
||||||
|
|
||||||
err := inv.Run()
|
err := inv.Run()
|
||||||
assert.ErrorContains(t, err, "are not logged in")
|
assert.ErrorContains(t, err, "are not logged in")
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:tparallel,paralleltest
|
//nolint:tparallel,paralleltest
|
||||||
|
Reference in New Issue
Block a user