Skip to content

Commit 794e7c7

Browse files
committed
add fetch error test
1 parent 437c0f0 commit 794e7c7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cli/cliui/agent_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/google/uuid"
1313
"github.com/stretchr/testify/require"
14+
"golang.org/x/xerrors"
1415

1516
"github.com/coder/coder/cli/clibase"
1617
"github.com/coder/coder/cli/clitest"
@@ -251,6 +252,29 @@ func TestAgent(t *testing.T) {
251252
},
252253
wantErr: true,
253254
},
255+
{
256+
name: "Error during fetch",
257+
opts: cliui.AgentOptions{
258+
FetchInterval: time.Millisecond,
259+
Wait: true,
260+
},
261+
iter: []func(context.Context, *codersdk.WorkspaceAgent, chan []codersdk.WorkspaceAgentStartupLog) error{
262+
func(_ context.Context, agent *codersdk.WorkspaceAgent, _ chan []codersdk.WorkspaceAgentStartupLog) error {
263+
agent.Status = codersdk.WorkspaceAgentConnecting
264+
return nil
265+
},
266+
func(_ context.Context, agent *codersdk.WorkspaceAgent, _ chan []codersdk.WorkspaceAgentStartupLog) error {
267+
return nil
268+
},
269+
func(_ context.Context, agent *codersdk.WorkspaceAgent, _ chan []codersdk.WorkspaceAgentStartupLog) error {
270+
return xerrors.New("bad")
271+
},
272+
},
273+
want: []string{
274+
"⧗ Waiting for initial connection from the workspace agent",
275+
},
276+
wantErr: true,
277+
},
254278
} {
255279
tc := tc
256280
t.Run(tc.name, func(t *testing.T) {

0 commit comments

Comments
 (0)