10000 chore(cli): fix test flake in TestSSH_Container/NotFound by johnstcn · Pull Request #16771 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore(cli): fix test flake in TestSSH_Container/NotFound #16771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Changes from all commits
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
chore(cli): fix test flake in TestSSH_Container/NotFound
  • Loading branch information
johnstcn committed Mar 3, 2025
commit 09e1f5f8f00fe2f2af16d445864fe30b9f51997d
22 changes: 19 additions & 3 deletions cli/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ import (
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"golang.org/x/crypto/ssh"
gosshagent "golang.org/x/crypto/ssh/agent"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"

"github.com/coder/coder/v2/agent"
"github.com/coder/coder/v2/agent/agentcontainers"
"github.com/coder/coder/v2/agent/agentcontainers/acmock"
"github.com/coder/coder/v2/agent/agentssh"
"github.com/coder/coder/v2/agent/agenttest"
agentproto "github.com/coder/coder/v2/agent/proto"
Expand Down Expand Up @@ -1986,13 +1988,26 @@ func TestSSH_Container(t *testing.T) {

ctx := testutil.Context(t, testutil.WaitShort)
client, workspace, agentToken := setupWorkspaceForAgent(t)
ctrl := gomock.NewController(t)
mLister := acmock.NewMockLister(ctrl)
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
o.ExperimentalDevcontainersEnabled = true
o.ContainerLister = agentcontainers.NewDocker(o.Execer)
o.ContainerLister = mLister
})
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()

inv, root := clitest.New(t, "ssh", workspace.Name, "-c", uuid.NewString())
mLister.EXPECT().List(gomock.Any()).Return(codersdk.WorkspaceAgentListContainersResponse{
Containers: []codersdk.WorkspaceAgentDevcontainer{
{
ID: uuid.NewString(),
FriendlyName: "something_completely_different",
},
},
Warnings: nil,
}, nil)

cID := uuid.NewString()
inv, root := clitest.New(t, "ssh", workspace.Name, "-c", cID)
clitest.SetupConfig(t, client, root)
ptty := ptytest.New(t).Attach(inv)

Expand All @@ -2001,7 +2016,8 @@ func 5FA5 TestSSH_Container(t *testing.T) {
assert.NoError(t, err)
})

ptty.ExpectMatch("Container not found:")
ptty.ExpectMatch(fmt.Sprintf("Container not found: %q", cID))
ptty.ExpectMatch("Available containers: [something_completely_different]")
<-cmdDone
})

Expand Down
Loading
0