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

Function seedWorkspaceWithAgent

coderd/x/chatd/chatd_test.go:6255–6294  ·  view source on GitHub ↗

seedWorkspaceWithAgent creates a full workspace chain with a connected agent. This is the common setup needed by tests that exercise tool execution against a workspace.

(
	t *testing.T,
	db database.Store,
	userID uuid.UUID,
)

Source from the content-addressed store, hash-verified

6253// agent. This is the common setup needed by tests that exercise tool
6254// execution against a workspace.
6255func seedWorkspaceWithAgent(
6256 t *testing.T,
6257 db database.Store,
6258 userID uuid.UUID,
6259) (database.WorkspaceTable, database.WorkspaceAgent) {
6260 t.Helper()
6261
6262 org := dbgen.Organization(t, db, database.Organization{})
6263 tv := dbgen.TemplateVersion(t, db, database.TemplateVersion{
6264 OrganizationID: org.ID,
6265 CreatedBy: userID,
6266 })
6267 tpl := dbgen.Template(t, db, database.Template{
6268 CreatedBy: userID,
6269 OrganizationID: org.ID,
6270 ActiveVersionID: tv.ID,
6271 })
6272 ws := dbgen.Workspace(t, db, database.WorkspaceTable{
6273 TemplateID: tpl.ID,
6274 OwnerID: userID,
6275 OrganizationID: org.ID,
6276 })
6277 pj := dbgen.ProvisionerJob(t, db, nil, database.ProvisionerJob{
6278 InitiatorID: userID,
6279 OrganizationID: org.ID,
6280 })
6281 _ = dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{
6282 TemplateVersionID: tv.ID,
6283 WorkspaceID: ws.ID,
6284 JobID: pj.ID,
6285 })
6286 res := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{
6287 Transition: database.WorkspaceTransitionStart,
6288 JobID: pj.ID,
6289 })
6290 dbAgent := dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{
6291 ResourceID: res.ID,
6292 })
6293 return ws, dbAgent
6294}
6295
6296func setOpenAIProviderBaseURL(
6297 ctx context.Context,

Calls 9

OrganizationFunction · 0.92
TemplateVersionFunction · 0.92
TemplateFunction · 0.92
WorkspaceFunction · 0.92
ProvisionerJobFunction · 0.92
WorkspaceBuildFunction · 0.92
WorkspaceResourceFunction · 0.92
WorkspaceAgentFunction · 0.92
HelperMethod · 0.65

Tested by

no test coverage detected