(t *testing.T)
| 1365 | } |
| 1366 | |
| 1367 | func TestProjectV2Item_UnmarshalJSON_PullRequest(t *testing.T) { |
| 1368 | t.Parallel() |
| 1369 | |
| 1370 | // Test unmarshaling a pull request |
| 1371 | jsonData := `{ |
| 1372 | "id": 124, |
| 1373 | "node_id": "PVTI_pr", |
| 1374 | "content_type": "PullRequest", |
| 1375 | "content": { |
| 1376 | "id": 457, |
| 1377 | "number": 20, |
| 1378 | "title": "Test PR", |
| 1379 | "state": "closed", |
| 1380 | "merged": true, |
| 1381 | "merge_commit_sha": "abc123", |
| 1382 | "head": { |
| 1383 | "ref": "feature-branch", |
| 1384 | "sha": "def456" |
| 1385 | }, |
| 1386 | "base": { |
| 1387 | "ref": "main", |
| 1388 | "sha": "ghi789" |
| 1389 | } |
| 1390 | }, |
| 1391 | "created_at": "2023-01-02T00:00:00Z" |
| 1392 | }` |
| 1393 | |
| 1394 | var item ProjectV2Item |
| 1395 | if err := json.Unmarshal([]byte(jsonData), &item); err != nil { |
| 1396 | t.Fatalf("json.Unmarshal failed: %v", err) |
| 1397 | } |
| 1398 | |
| 1399 | // Verify basic fields |
| 1400 | if item.GetID() != 124 { |
| 1401 | t.Errorf("ID = %v, want 124", item.GetID()) |
| 1402 | } |
| 1403 | if item.ContentType == nil || *item.ContentType != ProjectV2ItemContentTypePullRequest { |
| 1404 | t.Errorf("ContentType = %v, want PullRequest", item.ContentType) |
| 1405 | } |
| 1406 | |
| 1407 | // Verify content is unmarshaled as PullRequest |
| 1408 | if item.Content == nil { |
| 1409 | t.Fatal("Content is nil") |
| 1410 | } |
| 1411 | if item.GetContent().GetPullRequest() == nil { |
| 1412 | t.Fatal("Content.PullRequest is nil") |
| 1413 | } |
| 1414 | if item.GetContent().GetPullRequest().GetNumber() != 20 { |
| 1415 | t.Errorf("PullRequest.Number = %v, want 20", item.GetContent().GetPullRequest().GetNumber()) |
| 1416 | } |
| 1417 | if item.GetContent().GetPullRequest().GetTitle() != "Test PR" { |
| 1418 | t.Errorf("PullRequest.Title = %v, want Test PR", item.GetContent().GetPullRequest().GetTitle()) |
| 1419 | } |
| 1420 | if !item.GetContent().GetPullRequest().GetMerged() { |
| 1421 | t.Errorf("PullRequest.Merged = %t, want true", item.GetContent().GetPullRequest().GetMerged()) |
| 1422 | } |
| 1423 | if item.GetContent().GetPullRequest().GetMergeCommitSHA() != "abc123" { |
| 1424 | t.Errorf("PullRequest.MergeCommitSHA = %v, want abc123", item.GetContent().GetPullRequest().GetMergeCommitSHA()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…