From 09e1f5f8f00fe2f2af16d445864fe30b9f51997d Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 3 Mar 2025 13:08:35 +0000 Subject: [PATCH] chore(cli): fix test flake in TestSSH_Container/NotFound --- cli/ssh_test.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cli/ssh_test.go b/cli/ssh_test.go index 8a8d2d6ef3f6f..1fd4069ae3aea 100644 --- a/cli/ssh_test.go +++ b/cli/ssh_test.go @@ -29,6 +29,7 @@ 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" @@ -36,6 +37,7 @@ import ( "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" @@ -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) @@ -2001,7 +2016,8 @@ func 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 }) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy