@@ -107,6 +107,70 @@ func TestIssue_ExportData(t *testing.T) {
107107 }
108108 ` ),
109109 },
110+ {
111+ name : "linked pull requests" ,
112+ fields : []string {"closedByPullRequestsReferences" },
113+ inputJSON : heredoc .Doc (`
114+ { "closedByPullRequestsReferences": { "nodes": [
115+ {
116+ "id": "I_123",
117+ "number": 123,
118+ "url": "https://github.com/cli/cli/pull/123",
119+ "repository": {
120+ "id": "R_123",
121+ "name": "cli",
122+ "owner": {
123+ "id": "O_123",
124+ "login": "cli"
125+ }
126+ }
127+ },
128+ {
129+ "id": "I_456",
130+ "number": 456,
131+ "url": "https://github.com/cli/cli/pull/456",
132+ "repository": {
133+ "id": "R_456",
134+ "name": "cli",
135+ "owner": {
136+ "id": "O_456",
137+ "login": "cli"
138+ }
139+ }
140+ }
141+ ] } }
142+ ` ),
143+ outputJSON : heredoc .Doc (`
144+ { "closedByPullRequestsReferences": [
145+ {
146+ "id": "I_123",
147+ "number": 123,
148+ "repository": {
149+ "id": "R_123",
150+ "name": "cli",
151+ "owner": {
152+ "id": "O_123",
153+ "login": "cli"
154+ }
155+ },
156+ "url": "https://github.com/cli/cli/pull/123"
157+ },
158+ {
159+ "id": "I_456",
160+ "number": 456,
161+ "repository": {
162+ "id": "R_456",
163+ "name": "cli",
164+ "owner": {
165+ "id": "O_456",
166+ "login": "cli"
167+ }
168+ },
169+ "url": "https://github.com/cli/cli/pull/456"
170+ }
171+ ] }
172+ ` ),
173+ },
110174 }
111175 for _ , tt := range tests {
112176 t .Run (tt .name , func (t * testing.T ) {
@@ -120,7 +184,14 @@ func TestIssue_ExportData(t *testing.T) {
120184 enc := json .NewEncoder (& buf )
121185 enc .SetIndent ("" , "\t " )
122186 require .NoError (t , enc .Encode (exported ))
123- assert .Equal (t , tt .outputJSON , buf .String ())
187+
188+ var gotData interface {}
189+ dec = json .NewDecoder (& buf )
190+ require .NoError (t , dec .Decode (& gotData ))
191+ var expectData interface {}
192+ require .NoError (t , json .Unmarshal ([]byte (tt .outputJSON ), & expectData ))
193+
194+ assert .Equal (t , expectData , gotData )
124195 })
125196 }
126197}
@@ -245,6 +316,70 @@ func TestPullRequest_ExportData(t *testing.T) {
245316 }
246317 ` ),
247318 },
319+ {
320+ name : "linked issues" ,
321+ fields : []string {"closingIssuesReferences" },
322+ inputJSON : heredoc .Doc (`
323+ { "closingIssuesReferences": { "nodes": [
324+ {
325+ "id": "I_123",
326+ "number": 123,
327+ "url": "https://github.com/cli/cli/issues/123",
328+ "repository": {
329+ "id": "R_123",
330+ "name": "cli",
331+ "owner": {
332+ "id": "O_123",
333+ "login": "cli"
334+ }
335+ }
336+ },
337+ {
338+ "id": "I_456",
339+ "number": 456,
340+ "url": "https://github.com/cli/cli/issues/456",
341+ "repository": {
342+ "id": "R_456",
343+ "name": "cli",
344+ "owner": {
345+ "id": "O_456",
346+ "login": "cli"
347+ }
348+ }
349+ }
350+ ] } }
351+ ` ),
352+ outputJSON : heredoc .Doc (`
353+ { "closingIssuesReferences": [
354+ {
355+ "id": "I_123",
356+ "number": 123,
357+ "repository": {
358+ "id": "R_123",
359+ "name": "cli",
360+ "owner": {
361+ "id": "O_123",
362+ "login": "cli"
363+ }
364+ },
365+ "url": "https://github.com/cli/cli/issues/123"
366+ },
367+ {
368+ "id": "I_456",
369+ "number": 456,
370+ "repository": {
371+ "id": "R_456",
372+ "name": "cli",
373+ "owner": {
374+ "id": "O_456",
375+ "login": "cli"
376+ }
377+ },
378+ "url": "https://github.com/cli/cli/issues/456"
379+ }
380+ ] }
381+ ` ),
382+ },
248383 }
249384 for _ , tt := range tests {
250385 t .Run (tt .name , func (t * testing.T ) {
0 commit comments