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

Function createAITaskTemplate

cli/task_test.go:457–512  ·  view source on GitHub ↗

createAITaskTemplate creates a template configured for AI tasks with a sidebar app.

(t *testing.T, client *codersdk.Client, orgID uuid.UUID, opts ...aiTemplateOpt)

Source from the content-addressed store, hash-verified

455
456// createAITaskTemplate creates a template configured for AI tasks with a sidebar app.
457func createAITaskTemplate(t *testing.T, client *codersdk.Client, orgID uuid.UUID, opts ...aiTemplateOpt) codersdk.Template {
458 t.Helper()
459
460 opt := aiTemplateOpts{
461 authToken: uuid.NewString(),
462 }
463 for _, o := range opts {
464 o(&opt)
465 }
466
467 taskAppID := uuid.New()
468 version := coderdtest.CreateTemplateVersion(t, client, orgID, &echo.Responses{
469 Parse: echo.ParseComplete,
470 ProvisionGraph: []*proto.Response{
471 {
472 Type: &proto.Response_Graph{
473 Graph: &proto.GraphComplete{
474 Resources: []*proto.Resource{
475 {
476 Name: "example",
477 Type: "aws_instance",
478 Agents: []*proto.Agent{
479 {
480 Id: uuid.NewString(),
481 Name: "example",
482 Auth: &proto.Agent_Token{
483 Token: opt.authToken,
484 },
485 Apps: []*proto.App{
486 {
487 Id: taskAppID.String(),
488 Slug: "task-sidebar",
489 DisplayName: "Task Sidebar",
490 Url: opt.appURL,
491 },
492 },
493 },
494 },
495 },
496 },
497 HasAiTasks: true,
498 AiTasks: []*proto.AITask{
499 {
500 AppId: taskAppID.String(),
501 },
502 },
503 },
504 },
505 },
506 },
507 })
508 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
509 template := coderdtest.CreateTemplate(t, client, orgID, version.ID)
510
511 return template
512}
513
514// fakeAgentAPI implements a fake AgentAPI HTTP server for testing.

Callers 2

Test_TasksFunction · 0.85
setupCLITaskTestFunction · 0.85

Calls 6

CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
HelperMethod · 0.65
NewMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected