(t *testing.T)
| 94 | } |
| 95 | |
| 96 | func 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 | }, |
nothing calls this directly
no test coverage detected