nolint:tparallel,paralleltest // Sub tests need to run sequentially.
(t *testing.T)
| 4790 | |
| 4791 | //nolint:tparallel,paralleltest // Sub tests need to run sequentially. |
| 4792 | func TestWorkspaceAITask(t *testing.T) { |
| 4793 | t.Parallel() |
| 4794 | |
| 4795 | usage := coderdtest.NewUsageInserter() |
| 4796 | owner, _, first := coderdenttest.NewWithDatabase(t, &coderdenttest.Options{ |
| 4797 | Options: &coderdtest.Options{ |
| 4798 | UsageInserter: usage, |
| 4799 | IncludeProvisionerDaemon: true, |
| 4800 | }, |
| 4801 | LicenseOptions: (&coderdenttest.LicenseOptions{ |
| 4802 | Features: license.Features{ |
| 4803 | codersdk.FeatureTemplateRBAC: 1, |
| 4804 | }, |
| 4805 | }).ManagedAgentLimit(10), |
| 4806 | }) |
| 4807 | |
| 4808 | client, _ := coderdtest.CreateAnotherUser(t, owner, first.OrganizationID, |
| 4809 | rbac.RoleTemplateAdmin(), rbac.RoleUserAdmin()) |
| 4810 | |
| 4811 | graphWithTask := []*proto.Response{{ |
| 4812 | Type: &proto.Response_Graph{ |
| 4813 | Graph: &proto.GraphComplete{ |
| 4814 | Error: "", |
| 4815 | Timings: nil, |
| 4816 | Resources: nil, |
| 4817 | Parameters: nil, |
| 4818 | ExternalAuthProviders: nil, |
| 4819 | Presets: nil, |
| 4820 | HasAiTasks: true, |
| 4821 | AiTasks: []*proto.AITask{ |
| 4822 | { |
| 4823 | Id: "test", |
| 4824 | SidebarApp: nil, |
| 4825 | AppId: "test", |
| 4826 | }, |
| 4827 | }, |
| 4828 | HasExternalAgents: false, |
| 4829 | }, |
| 4830 | }, |
| 4831 | }} |
| 4832 | planWithTask := []*proto.Response{{ |
| 4833 | Type: &proto.Response_Plan{ |
| 4834 | Plan: &proto.PlanComplete{ |
| 4835 | Plan: []byte("{}"), |
| 4836 | AiTaskCount: 1, |
| 4837 | }, |
| 4838 | }, |
| 4839 | }} |
| 4840 | |
| 4841 | t.Run("CreateWorkspaceWithTaskNormally", func(t *testing.T) { |
| 4842 | // Creating a workspace that has agentic tasks, but is not launced via task |
| 4843 | // should not count towards the usage. |
| 4844 | t.Cleanup(usage.Reset) |
| 4845 | version := coderdtest.CreateTemplateVersion(t, client, first.OrganizationID, &echo.Responses{ |
| 4846 | Parse: echo.ParseComplete, |
| 4847 | ProvisionInit: echo.InitComplete, |
| 4848 | ProvisionPlan: planWithTask, |
| 4849 | ProvisionApply: echo.ApplyComplete, |
nothing calls this directly
no test coverage detected