MCPcopy
hub / github.com/cli/cli / TestCreateJob

Function TestCreateJob

pkg/cmd/agent-task/capi/job_test.go:200–427  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func TestCreateJob(t *testing.T) {
201 sampleDateString := "2025-08-29T00:00:00Z"
202 sampleDate, err := time.Parse(time.RFC3339, sampleDateString)
203 require.NoError(t, err)
204
205 tests := []struct {
206 name string
207 baseBranch string
208 customAgent string
209 httpStubs func(*testing.T, *httpmock.Registry)
210 wantErr string
211 wantOut *Job
212 }{
213 {
214 name: "success",
215 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
216 reg.Register(
217 httpmock.WithHost(httpmock.REST("POST", "agents/swe/v1/jobs/OWNER/REPO"), "api.githubcopilot.com"),
218 httpmock.RESTPayload(201,
219 heredoc.Docf(`
220 {
221 "job_id": "job123",
222 "session_id": "sess1",
223 "problem_statement": "Do the thing",
224 "event_type": "foo",
225 "content_filter_mode": "foo",
226 "status": "foo",
227 "result": "foo",
228 "actor": {
229 "id": 1,
230 "login": "octocat"
231 },
232 "created_at": "%[1]s",
233 "updated_at": "%[1]s"
234 }
235 `, sampleDateString),
236 func(payload map[string]interface{}) {
237 assert.Equal(t, "Do the thing", payload["problem_statement"])
238 assert.Equal(t, "gh_cli", payload["event_type"])
239 },
240 ),
241 )
242 },
243 wantOut: &Job{
244 ID: "job123",
245 SessionID: "sess1",
246 ProblemStatement: "Do the thing",
247 EventType: "foo",
248 ContentFilterMode: "foo",
249 Status: "foo",
250 Result: "foo",
251 Actor: &JobActor{
252 ID: 1,
253 Login: "octocat",
254 },
255 CreatedAt: sampleDate,
256 UpdatedAt: sampleDate,
257 },

Callers

nothing calls this directly

Calls 10

RegisterMethod · 0.95
VerifyMethod · 0.95
CreateJobMethod · 0.95
WithHostFunction · 0.92
RESTFunction · 0.92
RESTPayloadFunction · 0.92
StatusStringResponseFunction · 0.92
NewCAPIClientFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected