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

Function TestListTasks

coderd/database/querier_test.go:9759–9902  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9757}
9758
9759func TestListTasks(t *testing.T) {
9760 t.Parallel()
9761
9762 db, ps := dbtestutil.NewDB(t)
9763
9764 // Given: two organizations and two users, one of which is a member of both
9765 org1 := dbgen.Organization(t, db, database.Organization{})
9766 org2 := dbgen.Organization(t, db, database.Organization{})
9767 user1 := dbgen.User(t, db, database.User{})
9768 user2 := dbgen.User(t, db, database.User{})
9769 _ = dbgen.OrganizationMember(t, db, database.OrganizationMember{
9770 OrganizationID: org1.ID,
9771 UserID: user1.ID,
9772 })
9773 _ = dbgen.OrganizationMember(t, db, database.OrganizationMember{
9774 OrganizationID: org2.ID,
9775 UserID: user2.ID,
9776 })
9777
9778 // Given: a template with an active version
9779 tv := dbgen.TemplateVersion(t, db, database.TemplateVersion{
9780 CreatedBy: user1.ID,
9781 OrganizationID: org1.ID,
9782 })
9783 tpl := dbgen.Template(t, db, database.Template{
9784 CreatedBy: user1.ID,
9785 OrganizationID: org1.ID,
9786 ActiveVersionID: tv.ID,
9787 })
9788
9789 // Helper function to create a task
9790 createTask := func(orgID, ownerID uuid.UUID) database.Task {
9791 ws := dbgen.Workspace(t, db, database.WorkspaceTable{
9792 OrganizationID: orgID,
9793 OwnerID: ownerID,
9794 TemplateID: tpl.ID,
9795 })
9796 pj := dbgen.ProvisionerJob(t, db, ps, database.ProvisionerJob{})
9797 sidebarAppID := uuid.New()
9798 wb := dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{
9799 JobID: pj.ID,
9800 TemplateVersionID: tv.ID,
9801 WorkspaceID: ws.ID,
9802 })
9803 wr := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{
9804 JobID: pj.ID,
9805 })
9806 agt := dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{
9807 ResourceID: wr.ID,
9808 })
9809 wa := dbgen.WorkspaceApp(t, db, database.WorkspaceApp{
9810 ID: sidebarAppID,
9811 AgentID: agt.ID,
9812 })
9813 tsk := dbgen.Task(t, db, database.TaskTable{
9814 OrganizationID: orgID,
9815 OwnerID: ownerID,
9816 Prompt: testutil.GetRandomName(t),

Callers

nothing calls this directly

Calls 15

NewDBFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
OrganizationMemberFunction · 0.92
TemplateVersionFunction · 0.92
TemplateFunction · 0.92
WorkspaceFunction · 0.92
ProvisionerJobFunction · 0.92
WorkspaceBuildFunction · 0.92
WorkspaceResourceFunction · 0.92
WorkspaceAgentFunction · 0.92
WorkspaceAppFunction · 0.92

Tested by

no test coverage detected