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

Function TestTasks

coderd/aitasks_test.go:141–1467  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func 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(),

Callers

nothing calls this directly

Calls 15

StatusCodeMethod · 0.95
CloseMethod · 0.95
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
ContextFunction · 0.92
FindFunction · 0.92
NewWithDatabaseFunction · 0.92
CreateAnotherUserFunction · 0.92

Tested by

no test coverage detected