@@ -249,7 +249,6 @@ func TestUnmarshalToStructWithPointerAttr_BadType_Struct(t *testing.T) {
249
249
250
250
func TestUnmarshalToStructWithPointerAttr_BadType_IntSlice (t * testing.T ) {
251
251
out := new (WithPointer )
252
- type FooStruct struct { A , B int }
253
252
in := map [string ]interface {}{
254
253
"name" : []int {4 , 5 }, // This is the wrong type.
255
254
}
@@ -405,7 +404,9 @@ func TestUnmarshalNullableRelationshipsNonNullValue(t *testing.T) {
405
404
}
406
405
407
406
outBuf := bytes .NewBuffer (nil )
408
- json .NewEncoder (outBuf ).Encode (payload )
407
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
408
+ t .Fatal (err )
409
+ }
409
410
410
411
out := new (WithNullableAttrs )
411
412
@@ -442,7 +443,9 @@ func TestUnmarshalNullableRelationshipsExplicitNullValue(t *testing.T) {
442
443
}
443
444
444
445
outBuf := bytes .NewBuffer (nil )
445
- json .NewEncoder (outBuf ).Encode (payload )
446
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
447
+ t .Fatal (err )
448
+ }
446
449
447
450
out := new (WithNullableAttrs )
448
451
@@ -467,7 +470,9 @@ func TestUnmarshalNullableRelationshipsNonExistentValue(t *testing.T) {
467
470
}
468
471
469
472
outBuf := bytes .NewBuffer (nil )
470
- json .NewEncoder (outBuf ).Encode (payload )
473
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
474
+ t .Fatal (err )
475
+ }
471
476
472
477
out := new (WithNullableAttrs )
473
478
@@ -490,7 +495,9 @@ func TestUnmarshalNullableRelationshipsNoRelationships(t *testing.T) {
490
495
}
491
496
492
497
outBuf := bytes .NewBuffer (nil )
493
- json .NewEncoder (outBuf ).Encode (payload )
498
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
499
+ t .Fatal (err )
500
+ }
494
501
495
502
out := new (WithNullableAttrs )
496
503
@@ -1120,7 +1127,10 @@ func TestUnmarshalNestedRelationships(t *testing.T) {
1120
1127
}
1121
1128
1122
1129
func TestUnmarshalRelationshipsSerializedEmbedded (t * testing.T ) {
1123
- out := sampleSerializedEmbeddedTestModel ()
1130
+ out , err := sampleSerializedEmbeddedTestModel ()
1131
+ if err != nil {
1132
+ t .Fatal (err )
1133
+ }
1124
1134
1125
1135
if out .CurrentPost == nil {
1126
1136
t .Fatalf ("Current post was not materialized" )
@@ -1169,7 +1179,10 @@ func TestUnmarshalNestedRelationshipsEmbedded(t *testing.T) {
1169
1179
}
1170
1180
1171
1181
func TestUnmarshalRelationshipsSideloaded (t * testing.T ) {
1172
- payload := samplePayloadWithSideloaded ()
1182
+ payload , err := samplePayloadWithSideloaded ()
1183
+ if err != nil {
1184
+ t .Fatal (err )
1185
+ }
1173
1186
out := new (Blog )
1174
1187
1175
1188
if err := UnmarshalPayload (payload , out ); err != nil {
@@ -1190,7 +1203,10 @@ func TestUnmarshalRelationshipsSideloaded(t *testing.T) {
1190
1203
}
1191
1204
1192
1205
func TestUnmarshalNestedRelationshipsSideloaded (t * testing.T ) {
1193
- payload := samplePayloadWithSideloaded ()
1206
+ payload , err := samplePayloadWithSideloaded ()
1207
+ if err != nil {
1208
+ t .Fatal (err )
1209
+ }
1194
1210
out := new (Blog )
1195
1211
1196
1212
if err := UnmarshalPayload (payload , out ); err != nil {
@@ -1621,7 +1637,7 @@ func samplePayload() io.Reader {
1621
1637
}
1622
1638
1623
1639
out := bytes .NewBuffer (nil )
1624
- json .NewEncoder (out ).Encode (payload )
1640
+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
1625
1641
1626
1642
return out
1627
1643
}
@@ -1639,7 +1655,7 @@ func samplePayloadWithID() io.Reader {
1639
1655
}
1640
1656
1641
1657
out := bytes .NewBuffer (nil )
1642
- json .NewEncoder (out ).Encode (payload )
1658
+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
1643
1659
1644
1660
return out
1645
1661
}
@@ -1654,7 +1670,7 @@ func samplePayloadWithBadTypes(m map[string]interface{}) io.Reader {
1654
1670
}
1655
1671
1656
1672
out := bytes .NewBuffer (nil )
1657
- json .NewEncoder (out ).Encode (payload )
1673
+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
1658
1674
1659
1675
return out
1660
1676
}
@@ -1669,7 +1685,7 @@ func sampleWithPointerPayload(m map[string]interface{}) io.Reader {
1669
1685
}
1670
1686
1671
1687
out := bytes .NewBuffer (nil )
1672
- json .NewEncoder (out ).Encode (payload )
1688
+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
1673
1689
1674
1690
return out
1675
1691
}
@@ -1684,7 +1700,7 @@ func samplePayloadWithNullableAttrs(m map[string]interface{}) io.Reader {
1684
1700
}
1685
1701
1686
1702
out := bytes .NewBuffer (nil )
1687
- json .NewEncoder (out ).Encode (payload )
1703
+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
1688
1704
1689
1705
return out
1690
1706
}
@@ -1757,23 +1773,29 @@ func testModel() *Blog {
1757
1773
}
1758
1774
}
1759
1775
1760
- func samplePayloadWithSideloaded () io.Reader {
1776
+ func samplePayloadWithSideloaded () ( io.Reader , error ) {
1761
1777
testModel := testModel ()
1762
1778
1763
1779
out := bytes .NewBuffer (nil )
1764
- MarshalPayload (out , testModel )
1780
+ if err := MarshalPayload (out , testModel ); err != nil {
1781
+ return nil , err
1782
+ }
1765
1783
1766
- return out
1784
+ return out , nil
1767
1785
}
1768
1786
1769
- func sampleSerializedEmbeddedTestModel () * Blog {
1787
+ func sampleSerializedEmbeddedTestModel () ( * Blog , error ) {
1770
1788
out := bytes .NewBuffer (nil )
1771
- MarshalOnePayloadEmbedded (out , testModel ())
1789
+ if err := MarshalOnePayloadEmbedded (out , testModel ()); err != nil {
1790
+ return nil , err
1791
+ }
1772
1792
1773
1793
blog := new (Blog )
1774
- UnmarshalPayload (out , blog )
1794
+ if err := UnmarshalPayload (out , blog ); err != nil {
1795
+ return nil , err
1796
+ }
1775
1797
1776
- return blog
1798
+ return blog , nil
1777
1799
}
1778
1800
1779
1801
func TestUnmarshalNestedStructPtr (t * testing.T ) {
0 commit comments