MCPcopy Create free account
hub / github.com/cli/cli / TestCreateJob

Function TestCreateJob

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

Source from the content-addressed store, hash-verified

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

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