@@ -29,13 +29,15 @@ import (
29
29
"github.com/spf13/afero"
30
30
"github.com/stretchr/testify/assert"
31
31
"github.com/stretchr/testify/require"
32
+ "go.uber.org/mock/gomock"
32
33
"golang.org/x/crypto/ssh"
33
34
gosshagent "golang.org/x/crypto/ssh/agent"
34
35
"golang.org/x/sync/errgroup"
35
36
"golang.org/x/xerrors"
36
37
37
38
"github.com/coder/coder/v2/agent"
38
39
"github.com/coder/coder/v2/agent/agentcontainers"
40
+ "github.com/coder/coder/v2/agent/agentcontainers/acmock"
39
41
"github.com/coder/coder/v2/agent/agentssh"
40
42
"github.com/coder/coder/v2/agent/agenttest"
41
43
agentproto "github.com/coder/coder/v2/agent/proto"
@@ -1986,13 +1988,26 @@ func TestSSH_Container(t *testing.T) {
1986
1988
1987
1989
ctx := testutil .Context (t , testutil .WaitShort )
1988
1990
client , workspace , agentToken := setupWorkspaceForAgent (t )
1991
+ ctrl := gomock .NewController (t )
1992
+ mLister := acmock .NewMockLister (ctrl )
1989
1993
_ = agenttest .New (t , client .URL , agentToken , func (o * agent.Options ) {
1990
1994
o .ExperimentalDevcontainersEnabled = true
1991
- o .ContainerLister = agentcontainers . NewDocker ( o . Execer )
1995
+ o .ContainerLister = mLister
1992
1996
})
1993
1997
_ = coderdtest .NewWorkspaceAgentWaiter (t , client , workspace .ID ).Wait ()
1994
1998
1995
- inv , root := clitest .New (t , "ssh" , workspace .Name , "-c" , uuid .NewString ())
1999
+ mLister .EXPECT ().List (gomock .Any ()).Return (codersdk.WorkspaceAgentListContainersResponse {
2000
+ Containers : []codersdk.WorkspaceAgentDevcontainer {
2001
+ {
2002
+ ID : uuid .NewString (),
2003
+ FriendlyName : "something_completely_different" ,
2004
+ },
2005
+ },
2006
+ Warnings : nil ,
2007
+ }, nil )
2008
+
2009
+ cID := uuid .NewString ()
2010
+ inv , root := clitest .New (t , "ssh" , workspace .Name , "-c" , cID )
1996
2011
clitest .SetupConfig (t , client , root )
1997
2012
ptty := ptytest .New (t ).Attach (inv )
1998
2013
@@ -2001,7 +2016,8 @@ func TestSSH_Container(t *testing.T) {
2001
2016
assert .NoError (t , err )
2002
2017
})
2003
2018
2004
- ptty .ExpectMatch ("Container not found:" )
2019
+ ptty .ExpectMatch (fmt .Sprintf ("Container not found: %q" , cID ))
2020
+ ptty .ExpectMatch ("Available containers: [something_completely_different]" )
2005
2021
<- cmdDone
2006
2022
})
2007
2023
0 commit comments