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