(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestTasks(t *testing.T) { |
| 142 | t.Parallel() |
| 143 | |
| 144 | type aiTemplateOpts struct { |
| 145 | appURL string |
| 146 | authToken string |
| 147 | } |
| 148 | |
| 149 | type aiTemplateOpt func(*aiTemplateOpts) |
| 150 | |
| 151 | withSidebarURL := func(url string) aiTemplateOpt { return func(o *aiTemplateOpts) { o.appURL = url } } |
| 152 | withAgentToken := func(token string) aiTemplateOpt { return func(o *aiTemplateOpts) { o.authToken = token } } |
| 153 | |
| 154 | createAITemplate := func(t *testing.T, client *codersdk.Client, user codersdk.CreateFirstUserResponse, opts ...aiTemplateOpt) codersdk.Template { |
| 155 | t.Helper() |
| 156 | |
| 157 | opt := aiTemplateOpts{ |
| 158 | authToken: uuid.New().String(), |
| 159 | } |
| 160 | for _, o := range opts { |
| 161 | o(&opt) |
| 162 | } |
| 163 | |
| 164 | // Create a template version that supports AI tasks. |
| 165 | taskAppID := uuid.New() |
| 166 | version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ |
| 167 | Parse: echo.ParseComplete, |
| 168 | ProvisionGraph: []*proto.Response{ |
| 169 | { |
| 170 | Type: &proto.Response_Graph{ |
| 171 | Graph: &proto.GraphComplete{ |
| 172 | HasAiTasks: true, |
| 173 | Resources: []*proto.Resource{ |
| 174 | { |
| 175 | Name: "example", |
| 176 | Type: "aws_instance", |
| 177 | Agents: []*proto.Agent{ |
| 178 | { |
| 179 | Id: uuid.NewString(), |
| 180 | Name: "example", |
| 181 | Auth: &proto.Agent_Token{ |
| 182 | Token: opt.authToken, |
| 183 | }, |
| 184 | Apps: []*proto.App{ |
| 185 | { |
| 186 | Id: taskAppID.String(), |
| 187 | Slug: "task-app", |
| 188 | DisplayName: "Task App", |
| 189 | Url: opt.appURL, |
| 190 | }, |
| 191 | }, |
| 192 | }, |
| 193 | }, |
| 194 | }, |
| 195 | }, |
| 196 | AiTasks: []*proto.AITask{ |
| 197 | { |
| 198 | AppId: taskAppID.String(), |
nothing calls this directly
no test coverage detected