@@ -607,31 +607,7 @@ func TestUnmarshalRelationships(t *testing.T) {
607
607
}
608
608
}
609
609
610
- type Image struct {
611
- ID int `jsonapi:"primary,images"`
612
- Src string `jsonapi:"attr,src"`
613
- }
614
-
615
- type Video struct {
616
- ID int `jsonapi:"primary,videos"`
617
- Captions string `jsonapi:"attr,captions"`
618
- }
619
-
620
- type OneOfMedia struct {
621
- Image * Image
622
- random int
623
- Video * Video
624
- RandomStuff * string
625
- }
626
-
627
610
func Test_UnmarshalPayload_polymorphicRelations (t * testing.T ) {
628
- type pointerToOne struct {
629
- ID int `jsonapi:"primary,blogs"`
630
- Title string `jsonapi:"attr,title"`
631
- Hero * OneOfMedia `jsonapi:"polyrelation,hero-media,omitempty"`
632
- Media []* OneOfMedia `jsonapi:"polyrelation,media,omitempty"`
633
- }
634
-
635
611
in := bytes .NewReader ([]byte (`{
636
612
"data": {
637
613
"type": "blogs",
@@ -684,7 +660,7 @@ func Test_UnmarshalPayload_polymorphicRelations(t *testing.T) {
684
660
}
685
661
]
686
662
}` ))
687
- out := new (pointerToOne )
663
+ out := new (BlogPostWithPoly )
688
664
689
665
if err := UnmarshalPayload (in , out ); err != nil {
690
666
t .Fatal (err )
@@ -714,7 +690,7 @@ func Test_UnmarshalPayload_polymorphicRelations(t *testing.T) {
714
690
715
691
func Test_UnmarshalPayload_polymorphicRelations_no_choice (t * testing.T ) {
716
692
type pointerToOne struct {
717
- ID int `jsonapi:"primary,blogs"`
693
+ ID string `jsonapi:"primary,blogs"`
718
694
Title string `jsonapi:"attr,title"`
719
695
Hero * OneOfMedia `jsonapi:"polyrelation,hero-media,omitempty"`
720
696
}
0 commit comments