mirror of
https://codeberg.org/librarian/feeds
synced 2024-12-06 19:16:24 +01:00
fix JSONFeed Hubs (#74)
* fix JSONFeed Hubs * Add JSONHub test * fixed test output
This commit is contained in:
committed by
Matt Silverlock
parent
4eff0f5b76
commit
6f6e20dd39
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user