| 66 | } |
| 67 | |
| 68 | func (c Config) Validate() error { |
| 69 | if err := c.User.Validate(); err != nil { |
| 70 | return xerrors.Errorf("validate user: %w", err) |
| 71 | } |
| 72 | c.Workspace.OrganizationID = c.User.OrganizationID |
| 73 | // This value will be overwritten during the test. |
| 74 | c.Workspace.UserID = codersdk.Me |
| 75 | if err := c.Workspace.Validate(); err != nil { |
| 76 | return xerrors.Errorf("validate workspace: %w", err) |
| 77 | } |
| 78 | if c.ReconnectingPTY != nil { |
| 79 | // This value will be overwritten during the test. |
| 80 | c.ReconnectingPTY.AgentID = uuid.New() |
| 81 | if err := c.ReconnectingPTY.Validate(); err != nil { |
| 82 | return xerrors.Errorf("validate reconnecting pty: %w", err) |
| 83 | } |
| 84 | } |
| 85 | if c.AgentConn != nil { |
| 86 | // This value will be overwritten during the test. |
| 87 | c.AgentConn.AgentID = uuid.New() |
| 88 | if err := c.AgentConn.Validate(); err != nil { |
| 89 | return xerrors.Errorf("validate agent conn: %w", err) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return nil |
| 94 | } |