MCPcopy Create free account
hub / github.com/compozy/agh / TestTaskCreateAndListCommandsParseTaskFields

Function TestTaskCreateAndListCommandsParseTaskFields

internal/cli/task_test.go:190–340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestTaskCreateAndListCommandsParseTaskFields(t *testing.T) {
191 t.Parallel()
192
193 tests := []struct {
194 name string
195 run func(t *testing.T)
196 }{
197 {
198 name: "Should parse task create fields",
199 run: func(t *testing.T) {
200 t.Helper()
201
202 var createRequest CreateTaskRequest
203 deps := newTestDeps(t, &stubClient{
204 createTaskFn: func(_ context.Context, got CreateTaskRequest) (TaskRecord, error) {
205 createRequest = got
206 return sampleTaskRecord(), nil
207 },
208 })
209
210 createJSON, _, err := executeRootCommand(
211 t,
212 deps,
213 "task", "create",
214 "--id", "task-1",
215 "--identifier", "OPS-42",
216 "--scope", "workspace",
217 "--workspace", "alpha",
218 "--channel", "builders",
219 "--title", "Investigate flaky task runs",
220 "--description", "Capture root cause",
221 "--priority", "high",
222 "--owner-kind", "pool",
223 "--owner-ref", "triage",
224 "--metadata", `{"source":"qa"}`,
225 "-o", "json",
226 )
227 if err != nil {
228 t.Fatalf("task create error = %v", err)
229 }
230
231 if createRequest.Scope != taskpkg.ScopeWorkspace ||
232 createRequest.Workspace != "alpha" ||
233 createRequest.NetworkChannel != "builders" ||
234 createRequest.Title != "Investigate flaky task runs" ||
235 createRequest.Priority != taskpkg.PriorityHigh ||
236 createRequest.Owner == nil ||
237 createRequest.Owner.Kind != taskpkg.OwnerKindPool ||
238 createRequest.Owner.Ref != "triage" ||
239 string(createRequest.Metadata) != `{"source":"qa"}` {
240 t.Fatalf("createRequest = %#v, want parsed workspace/channel/owner/metadata", createRequest)
241 }
242
243 var created TaskRecord
244 if err := json.Unmarshal([]byte(createJSON), &created); err != nil {
245 t.Fatalf("json.Unmarshal(task create) error = %v", err)
246 }
247 if created.ID != "task-1" || created.Title != "Investigate flaky task runs" {

Callers

nothing calls this directly

Calls 6

newTestDepsFunction · 0.85
sampleTaskRecordFunction · 0.85
executeRootCommandFunction · 0.85
sampleTaskSummaryRecordFunction · 0.85
RunMethod · 0.65
runMethod · 0.65

Tested by

no test coverage detected