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

Function TestGetWorkspaceAgentsByParentID

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

Source from the content-addressed store, hash-verified

7637}
7638
7639func 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
7670func setupWorkspaceAgentQueryResources(t *testing.T, db database.Store, count int) []database.WorkspaceResource {
7671 t.Helper()

Callers

nothing calls this directly

Calls 9

NewDBFunction · 0.92
OrganizationFunction · 0.92
ProvisionerJobFunction · 0.92
WorkspaceResourceFunction · 0.92
WorkspaceAgentFunction · 0.92
ContextFunction · 0.92
RunMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected