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

Function Task

coderd/database/dbgen/dbgen.go:2048–2076  ·  view source on GitHub ↗
(t testing.TB, db database.Store, orig database.TaskTable)

Source from the content-addressed store, hash-verified

2046}
2047
2048func Task(t testing.TB, db database.Store, orig database.TaskTable) database.Task {
2049 t.Helper()
2050
2051 parameters := orig.TemplateParameters
2052 if parameters == nil {
2053 parameters = json.RawMessage([]byte("{}"))
2054 }
2055
2056 task, err := db.InsertTask(genCtx, database.InsertTaskParams{
2057 ID: takeFirst(orig.ID, uuid.New()),
2058 OrganizationID: orig.OrganizationID,
2059 OwnerID: orig.OwnerID,
2060 Name: takeFirst(orig.Name, testutil.GetRandomNameHyphenated(t)),
2061 DisplayName: takeFirst(orig.DisplayName, testutil.GetRandomNameHyphenated(t)),
2062 WorkspaceID: orig.WorkspaceID,
2063 TemplateVersionID: orig.TemplateVersionID,
2064 TemplateParameters: parameters,
2065 Prompt: orig.Prompt,
2066 CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
2067 })
2068 require.NoError(t, err, "failed to insert task")
2069
2070 // Return the Task from the view instead of the TaskTable
2071 fetched, err := db.GetTaskByID(genCtx, task.ID)
2072 require.NoError(t, err, "failed to fetch task")
2073 require.Equal(t, task.ID, fetched.ID)
2074
2075 return fetched
2076}
2077
2078func TaskWorkspaceApp(t testing.TB, db database.Store, orig database.TaskWorkspaceApp) database.TaskWorkspaceApp {
2079 t.Helper()

Callers 15

TestPauseTaskFunction · 0.92
TestResumeTaskFunction · 0.92
TestTaskParamFunction · 0.92
TestTelemetryFunction · 0.92
TestTasksTelemetryFunction · 0.92
TestTasksWithStatusViewFunction · 0.92
TestGetTaskByWorkspaceIDFunction · 0.92
TestTaskNameUniquenessFunction · 0.92
TestListTasksFunction · 0.92

Calls 8

GetRandomNameHyphenatedFunction · 0.92
NowFunction · 0.92
takeFirstFunction · 0.70
HelperMethod · 0.65
InsertTaskMethod · 0.65
NewMethod · 0.65
GetTaskByIDMethod · 0.65
EqualMethod · 0.45

Tested by 14

TestPauseTaskFunction · 0.74
TestResumeTaskFunction · 0.74
TestTaskParamFunction · 0.74
TestTelemetryFunction · 0.74
TestTasksTelemetryFunction · 0.74
TestTasksWithStatusViewFunction · 0.74
TestGetTaskByWorkspaceIDFunction · 0.74
TestTaskNameUniquenessFunction · 0.74
TestListTasksFunction · 0.74