Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit f79a192

Browse files
committed
add test uses annotationIgnore
1 parent 7d26540 commit f79a192

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

response_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,41 @@ func TestMarshalUnmarshalCompositeStruct(t *testing.T) {
10961096
},
10971097
})
10981098
}
1099+
1100+
{
1101+
type Model struct {
1102+
Thing `jsonapi:"-"`
1103+
ModelID int `jsonapi:"primary,models"`
1104+
Foo string `jsonapi:"attr,foo"`
1105+
Bar string `jsonapi:"attr,bar"`
1106+
Bat string `jsonapi:"attr,bat"`
1107+
Buzz int `jsonapi:"attr,buzz"`
1108+
}
1109+
1110+
scenarios = append(scenarios, test{
1111+
name: "Model embeds Thing, but is annotated w/ ignore",
1112+
dst: &Model{},
1113+
payload: &OnePayload{
1114+
Data: &Node{
1115+
Type: "models",
1116+
ID: "1",
1117+
Attributes: map[string]interface{}{
1118+
"bar": "barry",
1119+
"bat": "batty",
1120+
"buzz": 99,
1121+
"foo": "fooey",
1122+
},
1123+
},
1124+
},
1125+
expected: &Model{
1126+
ModelID: 1,
1127+
Foo: "fooey",
1128+
Bar: "barry",
1129+
Bat: "batty",
1130+
Buzz: 99,
1131+
},
1132+
})
1133+
}
10991134
for _, scenario := range scenarios {
11001135
t.Logf("running scenario: %s\n", scenario.name)
11011136

0 commit comments

Comments
 (0)