@@ -249,7 +249,6 @@ func TestUnmarshalToStructWithPointerAttr_BadType_Struct(t *testing.T) {
249249
250250func TestUnmarshalToStructWithPointerAttr_BadType_IntSlice (t * testing.T ) {
251251 out := new (WithPointer )
252- type FooStruct struct { A , B int }
253252 in := map [string ]interface {}{
254253 "name" : []int {4 , 5 }, // This is the wrong type.
255254 }
@@ -405,7 +404,9 @@ func TestUnmarshalNullableRelationshipsNonNullValue(t *testing.T) {
405404 }
406405
407406 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+ }
409410
410411 out := new (WithNullableAttrs )
411412
@@ -442,7 +443,9 @@ func TestUnmarshalNullableRelationshipsExplicitNullValue(t *testing.T) {
442443 }
443444
444445 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+ }
446449
447450 out := new (WithNullableAttrs )
448451
@@ -467,7 +470,9 @@ func TestUnmarshalNullableRelationshipsNonExistentValue(t *testing.T) {
467470 }
468471
469472 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+ }
471476
472477 out := new (WithNullableAttrs )
473478
@@ -490,7 +495,9 @@ func TestUnmarshalNullableRelationshipsNoRelationships(t *testing.T) {
490495 }
491496
492497 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+ }
494501
495502 out := new (WithNullableAttrs )
496503
@@ -1028,7 +1035,7 @@ func Test_choiceStructMapping(t *testing.T) {
10281035 t .Errorf ("expected \" images\" to be the first field, but got %d" , imageField .FieldNum )
10291036 }
10301037 videoField , ok := result ["videos" ]
1031- if ! ok || videoField .FieldNum != 2 {
1038+ if ! ok || videoField .FieldNum != 1 {
10321039 t .Errorf ("expected \" videos\" to be the third field, but got %d" , videoField .FieldNum )
10331040 }
10341041 }
@@ -1120,7 +1127,10 @@ func TestUnmarshalNestedRelationships(t *testing.T) {
11201127}
11211128
11221129func TestUnmarshalRelationshipsSerializedEmbedded (t * testing.T ) {
1123- out := sampleSerializedEmbeddedTestModel ()
1130+ out , err := sampleSerializedEmbeddedTestModel ()
1131+ if err != nil {
1132+ t .Fatal (err )
1133+ }
11241134
11251135 if out .CurrentPost == nil {
11261136 t .Fatalf ("Current post was not materialized" )
@@ -1169,7 +1179,10 @@ func TestUnmarshalNestedRelationshipsEmbedded(t *testing.T) {
11691179}
11701180
11711181func TestUnmarshalRelationshipsSideloaded (t * testing.T ) {
1172- payload := samplePayloadWithSideloaded ()
1182+ payload , err := samplePayloadWithSideloaded ()
1183+ if err != nil {
1184+ t .Fatal (err )
1185+ }
11731186 out := new (Blog )
11741187
11751188 if err := UnmarshalPayload (payload , out ); err != nil {
@@ -1190,7 +1203,10 @@ func TestUnmarshalRelationshipsSideloaded(t *testing.T) {
11901203}
11911204
11921205func TestUnmarshalNestedRelationshipsSideloaded (t * testing.T ) {
1193- payload := samplePayloadWithSideloaded ()
1206+ payload , err := samplePayloadWithSideloaded ()
1207+ if err != nil {
1208+ t .Fatal (err )
1209+ }
11941210 out := new (Blog )
11951211
11961212 if err := UnmarshalPayload (payload , out ); err != nil {
@@ -1621,7 +1637,7 @@ func samplePayload() io.Reader {
16211637 }
16221638
16231639 out := bytes .NewBuffer (nil )
1624- json .NewEncoder (out ).Encode (payload )
1640+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
16251641
16261642 return out
16271643}
@@ -1639,7 +1655,7 @@ func samplePayloadWithID() io.Reader {
16391655 }
16401656
16411657 out := bytes .NewBuffer (nil )
1642- json .NewEncoder (out ).Encode (payload )
1658+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
16431659
16441660 return out
16451661}
@@ -1654,7 +1670,7 @@ func samplePayloadWithBadTypes(m map[string]interface{}) io.Reader {
16541670 }
16551671
16561672 out := bytes .NewBuffer (nil )
1657- json .NewEncoder (out ).Encode (payload )
1673+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
16581674
16591675 return out
16601676}
@@ -1669,7 +1685,7 @@ func sampleWithPointerPayload(m map[string]interface{}) io.Reader {
16691685 }
16701686
16711687 out := bytes .NewBuffer (nil )
1672- json .NewEncoder (out ).Encode (payload )
1688+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
16731689
16741690 return out
16751691}
@@ -1684,7 +1700,7 @@ func samplePayloadWithNullableAttrs(m map[string]interface{}) io.Reader {
16841700 }
16851701
16861702 out := bytes .NewBuffer (nil )
1687- json .NewEncoder (out ).Encode (payload )
1703+ json .NewEncoder (out ).Encode (payload ) //nolint:errcheck
16881704
16891705 return out
16901706}
@@ -1757,23 +1773,29 @@ func testModel() *Blog {
17571773 }
17581774}
17591775
1760- func samplePayloadWithSideloaded () io.Reader {
1776+ func samplePayloadWithSideloaded () ( io.Reader , error ) {
17611777 testModel := testModel ()
17621778
17631779 out := bytes .NewBuffer (nil )
1764- MarshalPayload (out , testModel )
1780+ if err := MarshalPayload (out , testModel ); err != nil {
1781+ return nil , err
1782+ }
17651783
1766- return out
1784+ return out , nil
17671785}
17681786
1769- func sampleSerializedEmbeddedTestModel () * Blog {
1787+ func sampleSerializedEmbeddedTestModel () ( * Blog , error ) {
17701788 out := bytes .NewBuffer (nil )
1771- MarshalOnePayloadEmbedded (out , testModel ())
1789+ if err := MarshalOnePayloadEmbedded (out , testModel ()); err != nil {
1790+ return nil , err
1791+ }
17721792
17731793 blog := new (Blog )
1774- UnmarshalPayload (out , blog )
1794+ if err := UnmarshalPayload (out , blog ); err != nil {
1795+ return nil , err
1796+ }
17751797
1776- return blog
1798+ return blog , nil
17771799}
17781800
17791801func TestUnmarshalNestedStructPtr (t * testing.T ) {
0 commit comments