6
6
"errors"
7
7
"fmt"
8
8
"io"
9
+ "log"
9
10
"reflect"
10
11
"sort"
11
12
"strconv"
@@ -405,7 +406,9 @@ func TestUnmarshalNullableRelationshipsNonNullValue(t *testing.T) {
405
406
}
406
407
407
408
outBuf := bytes .NewBuffer (nil )
408
- json .NewEncoder (outBuf ).Encode (payload )
409
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
410
+ t .Fatalf ("failed to encode: %v" , err )
411
+ }
409
412
410
413
out := new (WithNullableAttrs )
411
414
@@ -442,7 +445,9 @@ func TestUnmarshalNullableRelationshipsExplicitNullValue(t *testing.T) {
442
445
}
443
446
444
447
outBuf := bytes .NewBuffer (nil )
445
- json .NewEncoder (outBuf ).Encode (payload )
448
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
449
+ t .Fatalf ("failed to encode: %v" , err )
450
+ }
446
451
447
452
out := new (WithNullableAttrs )
448
453
@@ -467,7 +472,9 @@ func TestUnmarshalNullableRelationshipsNonExistentValue(t *testing.T) {
467
472
}
468
473
469
474
outBuf := bytes .NewBuffer (nil )
470
- json .NewEncoder (outBuf ).Encode (payload )
475
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
476
+ log .Fatalf ("failed to encode: %v" , err )
477
+ }
471
478
472
479
out := new (WithNullableAttrs )
473
480
@@ -490,7 +497,9 @@ func TestUnmarshalNullableRelationshipsNoRelationships(t *testing.T) {
490
497
}
491
498
492
499
outBuf := bytes .NewBuffer (nil )
493
- json .NewEncoder (outBuf ).Encode (payload )
500
+ if err := json .NewEncoder (outBuf ).Encode (payload ); err != nil {
501
+ t .Fatalf ("failed to encode: %v" , err )
502
+ }
494
503
495
504
out := new (WithNullableAttrs )
496
505
@@ -1621,7 +1630,9 @@ func samplePayload() io.Reader {
1621
1630
}
1622
1631
1623
1632
out := bytes .NewBuffer (nil )
1624
- json .NewEncoder (out ).Encode (payload )
1633
+ if err := json .NewEncoder (out ).Encode (payload ); err != nil {
1634
+ log .Printf ("failed to encode: %v" , err )
1635
+ }
1625
1636
1626
1637
return out
1627
1638
}
@@ -1639,7 +1650,9 @@ func samplePayloadWithID() io.Reader {
1639
1650
}
1640
1651
1641
1652
out := bytes .NewBuffer (nil )
1642
- json .NewEncoder (out ).Encode (payload )
1653
+ if err := json .NewEncoder (out ).Encode (payload ); err != nil {
1654
+ log .Printf ("failed to encode: %v" , err )
1655
+ }
1643
1656
1644
1657
return out
1645
1658
}
@@ -1654,7 +1667,9 @@ func samplePayloadWithBadTypes(m map[string]interface{}) io.Reader {
1654
1667
}
1655
1668
1656
1669
out := bytes .NewBuffer (nil )
1657
- json .NewEncoder (out ).Encode (payload )
1670
+ if err := json .NewEncoder (out ).Encode (payload ); err != nil {
1671
+ log .Printf ("failed to encode: %v" , err )
1672
+ }
1658
1673
1659
1674
return out
1660
1675
}
@@ -1669,7 +1684,9 @@ func sampleWithPointerPayload(m map[string]interface{}) io.Reader {
1669
1684
}
1670
1685
1671
1686
out := bytes .NewBuffer (nil )
1672
- json .NewEncoder (out ).Encode (payload )
1687
+ if err := json .NewEncoder (out ).Encode (payload ); err != nil {
1688
+ log .Printf ("failed to encode: %v" , err )
1689
+ }
1673
1690
1674
1691
return out
1675
1692
}
@@ -1684,7 +1701,9 @@ func samplePayloadWithNullableAttrs(m map[string]interface{}) io.Reader {
1684
1701
}
1685
1702
1686
1703
out := bytes .NewBuffer (nil )
1687
- json .NewEncoder (out ).Encode (payload )
1704
+ if err := json .NewEncoder (out ).Encode (payload ); err != nil {
1705
+ log .Printf ("failed to encode: %v" , err )
1706
+ }
1688
1707
1689
1708
return out
1690
1709
}
@@ -1761,17 +1780,23 @@ func samplePayloadWithSideloaded() io.Reader {
1761
1780
testModel := testModel ()
1762
1781
1763
1782
out := bytes .NewBuffer (nil )
1764
- MarshalPayload (out , testModel )
1783
+ if err := MarshalPayload (out , testModel ); err != nil {
1784
+ log .Printf ("failed to marshal payload: %v" , err )
1785
+ }
1765
1786
1766
1787
return out
1767
1788
}
1768
1789
1769
1790
func sampleSerializedEmbeddedTestModel () * Blog {
1770
1791
out := bytes .NewBuffer (nil )
1771
- MarshalOnePayloadEmbedded (out , testModel ())
1792
+ if err := MarshalOnePayloadEmbedded (out , testModel ()); err != nil {
1793
+ log .Printf ("failed to marshal one payload embedded: %v" , err )
1794
+ }
1772
1795
1773
1796
blog := new (Blog )
1774
- UnmarshalPayload (out , blog )
1797
+ if err := UnmarshalPayload (out , blog ); err != nil {
1798
+ log .Printf ("failed to unmarshal payload: %v" , err )
1799
+ }
1775
1800
1776
1801
return blog
1777
1802
}
0 commit comments