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

Function TestProjectV2Item_UnmarshalJSON_Issue

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

Source from the content-addressed store, hash-verified

1301}
1302
1303func TestProjectV2Item_UnmarshalJSON_Issue(t *testing.T) {
1304 t.Parallel()
1305
1306 // Test unmarshaling an issue
1307 jsonData := `{
1308 "id": 123,
1309 "node_id": "PVTI_test",
1310 "content_type": "Issue",
1311 "content": {
1312 "id": 456,
1313 "number": 10,
1314 "title": "Test Issue",
1315 "state": "open",
1316 "body": "Issue body",
1317 "repository": {
1318 "id": 789,
1319 "name": "test-repo"
1320 }
1321 },
1322 "created_at": "2023-01-01T00:00:00Z"
1323 }`
1324
1325 var item ProjectV2Item
1326 if err := json.Unmarshal([]byte(jsonData), &item); err != nil {
1327 t.Fatalf("json.Unmarshal failed: %v", err)
1328 }
1329
1330 // Verify basic fields
1331 if item.GetID() != 123 {
1332 t.Errorf("ID = %v, want 123", item.GetID())
1333 }
1334 if item.GetNodeID() != "PVTI_test" {
1335 t.Errorf("NodeID = %v, want PVTI_test", item.GetNodeID())
1336 }
1337 if item.ContentType == nil || *item.ContentType != ProjectV2ItemContentTypeIssue {
1338 t.Errorf("ContentType = %v, want Issue", item.ContentType)
1339 }
1340
1341 // Verify content is unmarshaled as Issue
1342 if item.Content == nil {
1343 t.Fatal("Content is nil")
1344 }
1345 if item.GetContent().GetIssue() == nil {
1346 t.Fatal("Content.Issue is nil")
1347 }
1348 if item.GetContent().GetIssue().GetNumber() != 10 {
1349 t.Errorf("Issue.Number = %v, want 10", item.GetContent().GetIssue().GetNumber())
1350 }
1351 if item.GetContent().GetIssue().GetTitle() != "Test Issue" {
1352 t.Errorf("Issue.Title = %v, want Test Issue", item.GetContent().GetIssue().GetTitle())
1353 }
1354 if item.GetContent().GetIssue().GetState() != "open" {
1355 t.Errorf("Issue.State = %v, want open", item.GetContent().GetIssue().GetState())
1356 }
1357
1358 // Verify other content types are nil
1359 if item.GetContent().GetPullRequest() != nil {
1360 t.Error("Content.PullRequest should be nil for Issue content")

Callers

nothing calls this directly

Calls 10

GetIDMethod · 0.95
GetNodeIDMethod · 0.95
GetContentMethod · 0.95
GetDraftIssueMethod · 0.80
GetIssueMethod · 0.45
GetNumberMethod · 0.45
GetTitleMethod · 0.45
GetStateMethod · 0.45
GetPullRequestMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…