(t *testing.T)
| 1088 | } |
| 1089 | |
| 1090 | func TestAgentTaskCommandsMapLeaseRequests(t *testing.T) { |
| 1091 | t.Parallel() |
| 1092 | |
| 1093 | t.Run("Should map task next lease request", func(t *testing.T) { |
| 1094 | t.Parallel() |
| 1095 | |
| 1096 | var gotRequest AgentTaskClaimNextRequest |
| 1097 | deps := newAgentCommandTestDeps(t, &stubClient{ |
| 1098 | agentTaskClaimNextFn: func( |
| 1099 | _ context.Context, |
| 1100 | request AgentTaskClaimNextRequest, |
| 1101 | credentials agentidentity.Credentials, |
| 1102 | ) (AgentTaskNextRecord, error) { |
| 1103 | assertAgentCredentials(t, credentials) |
| 1104 | gotRequest = request |
| 1105 | return AgentTaskNextRecord{ |
| 1106 | Claimed: true, |
| 1107 | Claim: new(agentTaskClaimRecord()), |
| 1108 | }, nil |
| 1109 | }, |
| 1110 | }) |
| 1111 | |
| 1112 | stdout, _, err := executeRootCommand( |
| 1113 | t, |
| 1114 | deps, |
| 1115 | "task", |
| 1116 | "next", |
| 1117 | "--workspace-id", |
| 1118 | "ws-1", |
| 1119 | "--capability", |
| 1120 | "go", |
| 1121 | "--capability", |
| 1122 | " ", |
| 1123 | "--capability", |
| 1124 | "typescript", |
| 1125 | "--priority-min", |
| 1126 | "3", |
| 1127 | "--lease-seconds", |
| 1128 | "120", |
| 1129 | "--wait", |
| 1130 | "--idempotency-key", |
| 1131 | "idem-next", |
| 1132 | "-o", |
| 1133 | "json", |
| 1134 | ) |
| 1135 | if err != nil { |
| 1136 | t.Fatalf("task next error = %v", err) |
| 1137 | } |
| 1138 | if gotRequest.WorkspaceID != "ws-1" || |
| 1139 | gotRequest.PriorityMin != 3 || |
| 1140 | gotRequest.LeaseSeconds != 120 || |
| 1141 | !gotRequest.Wait || |
| 1142 | gotRequest.IdempotencyKey != "idem-next" || |
| 1143 | len(gotRequest.RequiredCapabilities) != 2 || |
| 1144 | gotRequest.RequiredCapabilities[0] != "go" || |
| 1145 | gotRequest.RequiredCapabilities[1] != "typescript" { |
| 1146 | t.Fatalf("next request = %#v, want parsed agent claim request", gotRequest) |
| 1147 | } |
nothing calls this directly
no test coverage detected