(t *testing.T)
| 198 | } |
| 199 | |
| 200 | func 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 | }, |
nothing calls this directly
no test coverage detected