(t *testing.T)
| 25 | } |
| 26 | |
| 27 | func 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(` |
nothing calls this directly
no test coverage detected