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

Function TestTaskBlockCommandsMapRequests

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

Source from the content-addressed store, hash-verified

340}
341
342func TestTaskBlockCommandsMapRequests(t *testing.T) {
343 t.Parallel()
344
345 t.Run("Should parse block request and render stable JSON", func(t *testing.T) {
346 t.Parallel()
347
348 var (
349 taskID string
350 blockRequest CreateTaskBlockRequest
351 )
352 deps := newTestDeps(t, &stubClient{
353 blockTaskFn: func(_ context.Context, id string, request CreateTaskBlockRequest) (TaskBlockRecord, error) {
354 taskID = id
355 blockRequest = request
356 return sampleTaskBlockRecord(), nil
357 },
358 })
359
360 stdout, _, err := executeRootCommand(
361 t,
362 deps,
363 "task",
364 "block",
365 "task-1",
366 "--kind",
367 "transient",
368 "--reason",
369 "waiting for quota",
370 "--details",
371 `{"queue":"gpu"}`,
372 "--expires-in",
373 "30m",
374 "-o",
375 "json",
376 )
377 if err != nil {
378 t.Fatalf("task block error = %v", err)
379 }
380 if taskID != "task-1" ||
381 blockRequest.Kind != taskpkg.BlockKindTransient ||
382 blockRequest.Reason != "waiting for quota" ||
383 blockRequest.RunID != "" ||
384 string(blockRequest.Details) != `{"queue":"gpu"}` ||
385 blockRequest.ExpiresAt == nil ||
386 !blockRequest.ExpiresAt.Equal(fixedTestNow.Add(30*time.Minute).UTC()) {
387 t.Fatalf("block request task=%q request=%#v, want parsed transient block", taskID, blockRequest)
388 }
389 var output TaskBlockRecord
390 if err := json.Unmarshal([]byte(stdout), &output); err != nil {
391 t.Fatalf("json.Unmarshal(task block) error = %v", err)
392 }
393 if output.ID != "block-1" || output.TaskID != "task-1" {
394 t.Fatalf("task block output = %#v, want block-1/task-1", output)
395 }
396 })
397
398 t.Run("Should reject run id without agent identity before calling the daemon", func(t *testing.T) {
399 t.Parallel()

Callers

nothing calls this directly

Calls 10

newTestDepsFunction · 0.85
sampleTaskBlockRecordFunction · 0.85
executeRootCommandFunction · 0.85
assertAgentCredentialsFunction · 0.85
sampleTaskRecordFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
AddMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected