Add tests

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-08-11 19:10:23 -04:00
parent 728087b874
commit 62054d2973
4 changed files with 86 additions and 15 deletions
+1 -5
View File
@@ -425,17 +425,13 @@ type PostAndComments struct {
// The 1st one contains the single post in its children array
// The 2nd one contains the comments to the post
func (pc *PostAndComments) UnmarshalJSON(data []byte) error {
var l []rootListing
var l [2]rootListing
err := json.Unmarshal(data, &l)
if err != nil {
return err
}
if len(l) < 2 {
return errors.New("unexpected json response when getting post")
}
post := l[0].getPosts().Posts[0]
comments := l[1].getComments().Comments
moreComments := l[1].getMoreComments()