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

Function TestMultipleAITasksDisallowed

coderd/workspaces_test.go:5610–5655  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5608}
5609
5610func TestMultipleAITasksDisallowed(t *testing.T) {
5611 t.Parallel()
5612
5613 db, pubsub := dbtestutil.NewDB(t)
5614 client := coderdtest.New(t, &coderdtest.Options{
5615 Database: db,
5616 Pubsub: pubsub,
5617 IncludeProvisionerDaemon: true,
5618 })
5619 user := coderdtest.CreateFirstUser(t, client)
5620
5621 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
5622 Parse: echo.ParseComplete,
5623 ProvisionGraph: []*proto.Response{{
5624 Type: &proto.Response_Graph{
5625 Graph: &proto.GraphComplete{
5626 HasAiTasks: true,
5627 AiTasks: []*proto.AITask{
5628 {
5629 Id: uuid.NewString(),
5630 SidebarApp: &proto.AITaskSidebarApp{
5631 Id: uuid.NewString(),
5632 },
5633 },
5634 {
5635 Id: uuid.NewString(),
5636 SidebarApp: &proto.AITaskSidebarApp{
5637 Id: uuid.NewString(),
5638 },
5639 },
5640 },
5641 },
5642 },
5643 }},
5644 })
5645 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
5646 template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
5647
5648 ws := coderdtest.CreateWorkspace(t, client, template.ID)
5649 coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws.LatestBuild.ID)
5650
5651 ctx := dbauthz.AsSystemRestricted(t.Context())
5652 pj, err := db.GetProvisionerJobByID(ctx, ws.LatestBuild.Job.ID)
5653 require.NoError(t, err)
5654 require.Contains(t, pj.Error.String, "only one 'coder_ai_task' resource can be provisioned per template")
5655}
5656
5657func TestUpdateWorkspaceACL(t *testing.T) {
5658 t.Parallel()

Callers

nothing calls this directly

Calls 12

NewDBFunction · 0.92
NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92
AsSystemRestrictedFunction · 0.92
ContextMethod · 0.65
GetProvisionerJobByIDMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected