MCPcopy Index your code
hub / github.com/google/go-github / TestProjectV2Item_UnmarshalJSON_DraftIssue

Function TestProjectV2Item_UnmarshalJSON_DraftIssue

github/projects_test.go:1436–1490  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1434}
1435
1436func TestProjectV2Item_UnmarshalJSON_DraftIssue(t *testing.T) {
1437 t.Parallel()
1438
1439 // Test unmarshaling a draft issue
1440 jsonData := `{
1441 "id": 125,
1442 "node_id": "PVTI_draft",
1443 "content_type": "DraftIssue",
1444 "content": {
1445 "id": 458,
1446 "node_id": "DI_test",
1447 "title": "Draft Issue Title",
1448 "body": "Draft issue body content"
1449 },
1450 "created_at": "2023-01-03T00:00:00Z"
1451 }`
1452
1453 var item ProjectV2Item
1454 if err := json.Unmarshal([]byte(jsonData), &item); err != nil {
1455 t.Fatalf("json.Unmarshal failed: %v", err)
1456 }
1457
1458 // Verify basic fields
1459 if item.GetID() != 125 {
1460 t.Errorf("ID = %v, want 125", item.GetID())
1461 }
1462 if item.ContentType == nil || *item.ContentType != ProjectV2ItemContentTypeDraftIssue {
1463 t.Errorf("ContentType = %v, want DraftIssue", item.ContentType)
1464 }
1465
1466 // Verify content is unmarshaled as DraftIssue
1467 if item.Content == nil {
1468 t.Fatal("Content is nil")
1469 }
1470 if item.GetContent().GetDraftIssue() == nil {
1471 t.Fatal("Content.DraftIssue is nil")
1472 }
1473 if item.GetContent().GetDraftIssue().GetID() != 458 {
1474 t.Errorf("DraftIssue.ID = %v, want 458", item.GetContent().GetDraftIssue().GetID())
1475 }
1476 if item.GetContent().GetDraftIssue().GetTitle() != "Draft Issue Title" {
1477 t.Errorf("DraftIssue.Title = %v, want Draft Issue Title", item.GetContent().GetDraftIssue().GetTitle())
1478 }
1479 if item.GetContent().GetDraftIssue().GetBody() != "Draft issue body content" {
1480 t.Errorf("DraftIssue.Body = %v, want Draft issue body content", item.GetContent().GetDraftIssue().GetBody())
1481 }
1482
1483 // Verify other content types are nil
1484 if item.GetContent().GetIssue() != nil {
1485 t.Error("Content.Issue should be nil for DraftIssue content")
1486 }
1487 if item.GetContent().GetPullRequest() != nil {
1488 t.Error("Content.PullRequest should be nil for DraftIssue content")
1489 }
1490}
1491
1492func TestProjectV2Item_UnmarshalJSON_NullContent(t *testing.T) {
1493 t.Parallel()

Callers

nothing calls this directly

Calls 9

GetIDMethod · 0.95
GetContentMethod · 0.95
GetDraftIssueMethod · 0.80
GetIDMethod · 0.45
GetTitleMethod · 0.45
GetBodyMethod · 0.45
GetIssueMethod · 0.45
ErrorMethod · 0.45
GetPullRequestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…