| 85 | } |
| 86 | |
| 87 | func Test_Config(t *testing.T) { |
| 88 | t.Parallel() |
| 89 | |
| 90 | id := uuid.New() |
| 91 | |
| 92 | userConfig := createworkspaces.UserConfig{ |
| 93 | OrganizationID: id, |
| 94 | Username: id.String(), |
| 95 | Email: id.String() + "@example.com", |
| 96 | } |
| 97 | |
| 98 | workspaceConfig := workspacebuild.Config{ |
| 99 | OrganizationID: id, |
| 100 | UserID: id.String(), |
| 101 | Request: codersdk.CreateWorkspaceRequest{ |
| 102 | TemplateID: id, |
| 103 | }, |
| 104 | } |
| 105 | |
| 106 | reconnectingPTYConfig := reconnectingpty.Config{ |
| 107 | AgentID: id, |
| 108 | } |
| 109 | |
| 110 | agentConnConfig := agentconn.Config{ |
| 111 | AgentID: id, |
| 112 | ConnectionMode: agentconn.ConnectionModeDirect, |
| 113 | HoldDuration: httpapi.Duration(time.Minute), |
| 114 | } |
| 115 | |
| 116 | cases := []struct { |
| 117 | name string |
| 118 | config createworkspaces.Config |
| 119 | errContains string |
| 120 | }{ |
| 121 | { |
| 122 | name: "OK", |
| 123 | config: createworkspaces.Config{ |
| 124 | User: userConfig, |
| 125 | Workspace: workspaceConfig, |
| 126 | ReconnectingPTY: &reconnectingPTYConfig, |
| 127 | AgentConn: &agentConnConfig, |
| 128 | }, |
| 129 | }, |
| 130 | { |
| 131 | name: "OKOptional", |
| 132 | config: createworkspaces.Config{ |
| 133 | User: userConfig, |
| 134 | Workspace: workspaceConfig, |
| 135 | ReconnectingPTY: nil, |
| 136 | AgentConn: nil, |
| 137 | }, |
| 138 | }, |
| 139 | { |
| 140 | name: "BadUserConfig", |
| 141 | config: createworkspaces.Config{ |
| 142 | User: createworkspaces.UserConfig{ |
| 143 | OrganizationID: uuid.Nil, |
| 144 | }, |