@@ -994,17 +994,6 @@ func TestNullableRelationship(t *testing.T) {
994
994
Body : "Hello World" ,
995
995
}
996
996
997
- comments := []* Comment {
998
- {
999
- ID : 6 ,
1000
- Body : "Hello World" ,
1001
- },
1002
- {
1003
- ID : 7 ,
1004
- Body : "Hello World" ,
1005
- },
1006
- }
1007
-
1008
997
for _ , tc := range []struct {
1009
998
desc string
1010
999
input * WithNullableAttrs
@@ -1032,11 +1021,15 @@ func TestNullableRelationship(t *testing.T) {
1032
1021
NullableComment : NewNullNullableRelationship [* Comment ](),
1033
1022
},
1034
1023
verification : func (root map [string ]interface {}) error {
1035
- _ , ok := root ["data" ].(map [string ]interface {})["relationships" ].(map [string ]interface {})["nullable_comment" ]
1024
+ commentData , ok := root ["data" ].(map [string ]interface {})["relationships" ].(map [string ]interface {})["nullable_comment" ].( map [ string ] interface {})[ "data " ]
1036
1025
1037
1026
if got , want := ok , true ; got != want {
1038
1027
return fmt .Errorf ("got %v, want %v" , got , want )
1039
1028
}
1029
+
1030
+ if commentData != nil {
1031
+ return fmt .Errorf ("Expected nil data for nullable_comment but was '%v'" , commentData )
1032
+ }
1040
1033
return nil
1041
1034
},
1042
1035
},
@@ -1057,58 +1050,6 @@ func TestNullableRelationship(t *testing.T) {
1057
1050
return nil
1058
1051
},
1059
1052
},
1060
- {
1061
- desc : "nullable_comments_unspecified" ,
1062
- input : & WithNullableAttrs {
1063
- ID : 5 ,
1064
- NullableComments : nil ,
1065
- },
1066
- verification : func (root map [string ]interface {}) error {
1067
- _ , ok := root ["data" ].(map [string ]interface {})["relationships" ]
1068
-
1069
- if got , want := ok , false ; got != want {
1070
- return fmt .Errorf ("got %v, want %v" , got , want )
1071
- }
1072
- return nil
1073
- },
1074
- },
1075
- {
1076
- desc : "nullable_comments_null" ,
1077
- input : & WithNullableAttrs {
1078
- ID : 5 ,
1079
- NullableComments : NewNullNullableRelationship [[]* Comment ](),
1080
- },
1081
- verification : func (root map [string ]interface {}) error {
1082
- _ , ok := root ["data" ].(map [string ]interface {})["relationships" ].(map [string ]interface {})["nullable_comments" ]
1083
-
1084
- if got , want := ok , true ; got != want {
1085
- return fmt .Errorf ("got %v, want %v" , got , want )
1086
- }
1087
- return nil
1088
- },
1089
- },
1090
- {
1091
- desc : "nullable_comments_not_null" ,
1092
- input : & WithNullableAttrs {
1093
- ID : 5 ,
1094
- NullableComments : NewNullableRelationshipWithValue (comments ),
1095
- },
1096
- verification : func (root map [string ]interface {}) error {
1097
- relationships := root ["data" ].(map [string ]interface {})["relationships" ]
1098
- nullableComments := relationships .(map [string ]interface {})["nullable_comments" ].(map [string ]interface {})["data" ].([]interface {})
1099
-
1100
- for i := 0 ; i < len (comments ); i ++ {
1101
- c := nullableComments [i ].(map [string ]interface {})
1102
- idStr := c ["id" ].(string )
1103
- id , _ := strconv .Atoi (idStr )
1104
- if got , want := id , comments [i ].ID ; got != want {
1105
- return fmt .Errorf ("got %v, want %v" , got , want )
1106
- }
1107
- }
1108
-
1109
- return nil
1110
- },
1111
- },
1112
1053
} {
1113
1054
t .Run (tc .desc , func (t * testing.T ) {
1114
1055
out := bytes .NewBuffer (nil )
0 commit comments