MCPcopy Index your code
hub / github.com/cli/cli / TestGetJob

Function TestGetJob

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

Source from the content-addressed store, hash-verified

25}
26
27func TestGetJob(t *testing.T) {
28 sampleDateString := "2025-08-29T00:00:00Z"
29 sampleDate, err := time.Parse(time.RFC3339, sampleDateString)
30 require.NoError(t, err)
31
32 tests := []struct {
33 name string
34 httpStubs func(*testing.T, *httpmock.Registry)
35 wantErr string
36 wantOut *Job
37 }{
38 {
39 name: "job without PR",
40 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
41 reg.Register(
42 httpmock.WithHost(httpmock.REST("GET", "agents/swe/v1/jobs/OWNER/REPO/job123"), "api.githubcopilot.com"),
43 httpmock.StatusStringResponse(200, heredoc.Docf(`
44 {
45 "job_id": "job123",
46 "session_id": "sess1",
47 "problem_statement": "Do the thing",
48 "event_type": "foo",
49 "content_filter_mode": "foo",
50 "status": "foo",
51 "result": "foo",
52 "actor": {
53 "id": 1,
54 "login": "octocat"
55 },
56 "created_at": "%[1]s",
57 "updated_at": "%[1]s"
58 }`,
59 sampleDateString,
60 )),
61 )
62 },
63 wantOut: &Job{
64 ID: "job123",
65 SessionID: "sess1",
66 ProblemStatement: "Do the thing",
67 EventType: "foo",
68 ContentFilterMode: "foo",
69 Status: "foo",
70 Result: "foo",
71 Actor: &JobActor{
72 ID: 1,
73 Login: "octocat",
74 },
75 CreatedAt: sampleDate,
76 UpdatedAt: sampleDate,
77 },
78 },
79 {
80 name: "job with PR",
81 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
82 reg.Register(
83 httpmock.WithHost(httpmock.REST("GET", "agents/swe/v1/jobs/OWNER/REPO/job123"), "api.githubcopilot.com"),
84 httpmock.StatusStringResponse(200, heredoc.Docf(`

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected