Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert "chore(cli): fix test flake in TestExpMcpServer"
This reverts commit 12405ae.
  • Loading branch information
johnstcn committed May 12, 2025
commit 90ad6fd8739f4f1fe899d908f0cae63a0bf6683e
42 changes: 18 additions & 24 deletions cli/exp_mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,35 +133,29 @@ func TestExpMcpServer(t *testing.T) {
require.Equal(t, 1.0, initializeResponse["id"])
require.NotNil(t, initializeResponse["result"])
})
}

t.Run("NoCredentials", func(t *testing.T) {
t.Parallel()

ctx := testutil.Context(t, testutil.WaitShort)
cancelCtx, cancel := context.WithCancel(ctx)
t.Cleanup(cancel)
func TestExpMcpServerNoCredentials(t *testing.T) {
// 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", "")

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

pty := ptytest.New(t)
inv.Stdin = pty.Input()
inv.Stdout = pty.Output()
inv.Stderr = pty.Output()
clitest.SetupConfig(t, client, root)
client := coderdtest.New(t, nil)
inv, root := clitest.New(t, "exp", "mcp", "server")
inv = inv.WithContext(cancelCtx)

cmdDone := make(chan struct{})
go func() {
defer close(cmdDone)
err := inv.Run()
assert.NoError(t, err)
}()
pty := ptytest.New(t)
inv.Stdin = pty.Input()
inv.Stdout = pty.Output()
clitest.SetupConfig(t, client, root)

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

//nolint:tparallel,paralleltest
Expand Down
Loading