Skip to content

Commit

Permalink
tests added goccy#405
Browse files Browse the repository at this point in the history
  • Loading branch information
cmetallo42 committed Nov 14, 2022
1 parent e435a84 commit 8ec03c4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4019,14 +4019,22 @@ func (p Property) IndexName() string {
}

func TestIssue405(t *testing.T) {
b := []byte(`{"name":"Test Property to remove"}`)
p := Property{}
t.Run("unmarshal", func(t *testing.T) {
b := []byte(`{"name":"Test Property to remove"}`)
p := Property{}

if err := json.Unmarshal(b, &p); err != nil {
t.Errorf("unexpected error: %v", err)
}
})
t.Run("stream", func(t *testing.T) {
r := strings.NewReader(`{"name":"Test Property to remove"}`)
p := Property{}

func(body []byte, doc EsDocument) {
if err := json.Unmarshal(body, &doc); err != nil {
if err := json.NewDecoder(r).Decode(&p); err != nil {
t.Errorf("unexpected error: %v", err)
}
}(b, &p)
})
}

func TestIssue406(t *testing.T) {
Expand Down

0 comments on commit 8ec03c4

Please sign in to comment.