@@ -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}
0 commit comments