(t *testing.T)
| 7637 | } |
| 7638 | |
| 7639 | func TestGetWorkspaceAgentsByParentID(t *testing.T) { |
| 7640 | t.Parallel() |
| 7641 | |
| 7642 | t.Run("NilParentDoesNotReturnAllParentAgents", func(t *testing.T) { |
| 7643 | t.Parallel() |
| 7644 | |
| 7645 | // Given: A workspace agent |
| 7646 | db, _ := dbtestutil.NewDB(t) |
| 7647 | org := dbgen.Organization(t, db, database.Organization{}) |
| 7648 | job := dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{ |
| 7649 | Type: database.ProvisionerJobTypeTemplateVersionImport, |
| 7650 | OrganizationID: org.ID, |
| 7651 | }) |
| 7652 | resource := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{ |
| 7653 | JobID: job.ID, |
| 7654 | }) |
| 7655 | _ = dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{ |
| 7656 | ResourceID: resource.ID, |
| 7657 | }) |
| 7658 | |
| 7659 | ctx := testutil.Context(t, testutil.WaitShort) |
| 7660 | |
| 7661 | // When: We attempt to select agents with a null parent id |
| 7662 | agents, err := db.GetWorkspaceAgentsByParentID(ctx, uuid.Nil) |
| 7663 | require.NoError(t, err) |
| 7664 | |
| 7665 | // Then: We expect to see no agents. |
| 7666 | require.Len(t, agents, 0) |
| 7667 | }) |
| 7668 | } |
| 7669 | |
| 7670 | func setupWorkspaceAgentQueryResources(t *testing.T, db database.Store, count int) []database.WorkspaceResource { |
| 7671 | t.Helper() |
nothing calls this directly
no test coverage detected