Skip to content

Commit

Permalink
fix JSONFeed Hubs (#74)
Browse files Browse the repository at this point in the history
* fix JSONFeed Hubs

* Add JSONHub test

* fixed test output
  • Loading branch information
wybiral authored and elithrar committed Jul 26, 2019
1 parent 4eff0f5 commit 6f6e20d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,34 @@ func TestFeedSorted(t *testing.T) {
t.Errorf("JSON not what was expected. Got:\n||%s||\n\nExpected:\n||%s||\n", got, jsonOutputSorted)
}
}

var jsonOutputHub = `{
"version": "https://jsonfeed.org/version/1",
"title": "feed title",
"hubs": [
{
"type": "WebSub",
"url": "https://websub-hub.example"
}
]
}`

func TestJSONHub(t *testing.T) {
feed := &JSONFeed{
Version: "https://jsonfeed.org/version/1",
Title: "feed title",
Hubs: []*JSONHub{
&JSONHub{
Type: "WebSub",
Url: "https://websub-hub.example",
},
},
}
json, err := feed.ToJSON()
if err != nil {
t.Errorf("unexpected error encoding JSON: %v", err)
}
if json != jsonOutputHub {
t.Errorf("JSON not what was expected. Got:\n%s\n\nExpected:\n%s\n", json, jsonOutputHub)
}
}
2 changes: 1 addition & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type JSONFeed struct {
Favicon string `json:"favicon,omitempty"`
Author *JSONAuthor `json:"author,omitempty"`
Expired *bool `json:"expired,omitempty"`
Hubs []*JSONItem `json:"hubs,omitempty"`
Hubs []*JSONHub `json:"hubs,omitempty"`
Items []*JSONItem `json:"items,omitempty"`
}

Expand Down

0 comments on commit 6f6e20d

Please sign in to comment.