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

Function TestUnixSocketClientTaskMethods

internal/cli/client_test.go:2335–2707  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2333}
2334
2335func TestUnixSocketClientTaskMethods(t *testing.T) {
2336 t.Parallel()
2337
2338 client := &unixSocketClient{
2339 socketPath: "/tmp/agh.sock",
2340 httpClient: &http.Client{
2341 Transport: roundTripperFunc(func(req *http.Request) (*http.Response, error) {
2342 switch {
2343 case req.Method == http.MethodGet && req.URL.Path == "/api/tasks":
2344 if got := req.URL.Query().Get("scope"); got != "workspace" {
2345 t.Fatalf("task scope query = %q, want %q", got, "workspace")
2346 }
2347 if got := req.URL.Query().Get("workspace"); got != "alpha" {
2348 t.Fatalf("task workspace query = %q, want %q", got, "alpha")
2349 }
2350 if got := req.URL.Query().Get("status"); got != "ready" {
2351 t.Fatalf("task status query = %q, want %q", got, "ready")
2352 }
2353 if got := req.URL.Query().Get("owner_kind"); got != "pool" {
2354 t.Fatalf("task owner_kind query = %q, want %q", got, "pool")
2355 }
2356 if got := req.URL.Query().Get("owner_ref"); got != "triage" {
2357 t.Fatalf("task owner_ref query = %q, want %q", got, "triage")
2358 }
2359 if got := req.URL.Query().Get("parent_task_id"); got != "task-root" {
2360 t.Fatalf("task parent_task_id query = %q, want %q", got, "task-root")
2361 }
2362 if got := req.URL.Query().Get("network_channel"); got != "builders" {
2363 t.Fatalf("task network_channel query = %q, want %q", got, "builders")
2364 }
2365 if got := req.URL.Query().Get("limit"); got != "3" {
2366 t.Fatalf("task limit query = %q, want %q", got, "3")
2367 }
2368 body := mustJSON(
2369 t,
2370 contract.TasksResponse{Tasks: []contract.TaskSummaryPayload{sampleTaskSummaryRecord()}},
2371 )
2372 return newHTTPResponse(http.StatusOK, string(body)), nil
2373 case req.Method == http.MethodPost && req.URL.Path == "/api/tasks":
2374 var payload contract.CreateTaskRequest
2375 if err := json.NewDecoder(req.Body).Decode(&payload); err != nil {
2376 t.Fatalf("json.Decode(create task body) error = %v", err)
2377 }
2378 if payload.Scope != taskpkg.ScopeWorkspace ||
2379 payload.Workspace != "alpha" ||
2380 payload.NetworkChannel != "builders" ||
2381 payload.Title != "Investigate flaky task runs" ||
2382 payload.Owner == nil ||
2383 payload.Owner.Kind != taskpkg.OwnerKindPool ||
2384 payload.Owner.Ref != "triage" {
2385 t.Fatalf("create task payload = %#v", payload)
2386 }
2387 body := mustJSON(t, contract.TaskResponse{Task: sampleTaskRecord()})
2388 return newHTTPResponse(http.StatusCreated, string(body)), nil
2389 case req.Method == http.MethodGet && req.URL.Path == "/api/tasks/task-1":
2390 body := mustJSON(t, contract.TaskDetailResponse{Task: sampleTaskDetailRecord()})
2391 return newHTTPResponse(http.StatusOK, string(body)), nil
2392 case req.Method == http.MethodPatch && req.URL.Path == "/api/tasks/task-1":

Callers

nothing calls this directly

Calls 15

ListTasksMethod · 0.95
CreateTaskMethod · 0.95
GetTaskMethod · 0.95
UpdateTaskMethod · 0.95
CancelTaskMethod · 0.95
CreateChildTaskMethod · 0.95
AddTaskDependencyMethod · 0.95
RemoveTaskDependencyMethod · 0.95
EnqueueTaskRunMethod · 0.95
ListTaskRunsMethod · 0.95
GetTaskRunMethod · 0.95
ClaimTaskRunMethod · 0.95

Tested by

no test coverage detected