MCPcopy Index your code
hub / github.com/coder/coder / TestWatcher_Agents

Function TestWatcher_Agents

coderd/workspaceconnwatcher/watcher_test.go:96–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestWatcher_Agents(t *testing.T) {
97 t.Parallel()
98
99 testCases := []struct {
100 name string
101 agents []database.WorkspaceAgent
102 agentDBError error
103 url string
104 expectedAgentUpdate *workspacesdk.AgentUpdate
105 expectedErrorCode workspacesdk.WatchErrorCode
106 expectedErrorRetryable bool
107 }{
108 {
109 name: "noNameSingleAgent",
110 agents: []database.WorkspaceAgent{
111 {
112 Name: "test",
113 ID: agentID,
114 LifecycleState: database.WorkspaceAgentLifecycleStateCreated,
115 },
116 },
117 url: "wss://local.test/",
118 expectedAgentUpdate: &workspacesdk.AgentUpdate{
119 Lifecycle: codersdk.WorkspaceAgentLifecycleCreated,
120 ID: agentID,
121 },
122 },
123 {
124 name: "noNameMultiAgent",
125 agents: []database.WorkspaceAgent{
126 {
127 Name: "agent0",
128 ID: agentID,
129 LifecycleState: database.WorkspaceAgentLifecycleStateCreated,
130 },
131 {
132 Name: "agent1",
133 ID: uuid.UUID{77},
134 LifecycleState: database.WorkspaceAgentLifecycleStateCreated,
135 },
136 },
137 url: "wss://local.test/",
138 expectedErrorCode: workspacesdk.WatchErrorTooManyAgents,
139 expectedErrorRetryable: false,
140 },
141 {
142 name: "namedAgentMultiAgent",
143 agents: []database.WorkspaceAgent{
144 {
145 Name: "agent0",
146 ID: agentID,
147 LifecycleState: database.WorkspaceAgentLifecycleStateCreated,
148 },
149 {
150 Name: "agent1",
151 ID: uuid.UUID{77},
152 LifecycleState: database.WorkspaceAgentLifecycleStateReady,
153 },

Callers

nothing calls this directly

Calls 14

ContextFunction · 0.92
LoggerFunction · 0.92
RequireReceiveFunction · 0.92
newHarnessFunction · 0.85
NewMethod · 0.65
RunMethod · 0.65
GetWorkspaceByIDMethod · 0.65
DialMethod · 0.65
CloseMethod · 0.65
EXPECTMethod · 0.45

Tested by

no test coverage detected