fix JSONFeed Hubs (#74)

* fix JSONFeed Hubs

* Add JSONHub test

* fixed test output
This commit is contained in:
davy wybiral
2019-07-26 18:58:42 -05:00
committed by Matt Silverlock
parent 4eff0f5b76
commit 6f6e20dd39
2 changed files with 32 additions and 1 deletions
+31
View File
@@ -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)
}
}
+1 -1
View File
@@ -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"`
}