Skip to content

Commit 6f6e20d

Browse files
wybiralelithrar
authored andcommitted
fix JSONFeed Hubs (#74)
* fix JSONFeed Hubs * Add JSONHub test * fixed test output
1 parent 4eff0f5 commit 6f6e20d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

feed_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,34 @@ func TestFeedSorted(t *testing.T) {
481481
t.Errorf("JSON not what was expected. Got:\n||%s||\n\nExpected:\n||%s||\n", got, jsonOutputSorted)
482482
}
483483
}
484+
485+
var jsonOutputHub = `{
486+
"version": "https://jsonfeed.org/version/1",
487+
"title": "feed title",
488+
"hubs": [
489+
{
490+
"type": "WebSub",
491+
"url": "https://websub-hub.example"
492+
}
493+
]
494+
}`
495+
496+
func TestJSONHub(t *testing.T) {
497+
feed := &JSONFeed{
498+
Version: "https://jsonfeed.org/version/1",
499+
Title: "feed title",
500+
Hubs: []*JSONHub{
501+
&JSONHub{
502+
Type: "WebSub",
503+
Url: "https://websub-hub.example",
504+
},
505+
},
506+
}
507+
json, err := feed.ToJSON()
508+
if err != nil {
509+
t.Errorf("unexpected error encoding JSON: %v", err)
510+
}
511+
if json != jsonOutputHub {
512+
t.Errorf("JSON not what was expected. Got:\n%s\n\nExpected:\n%s\n", json, jsonOutputHub)
513+
}
514+
}

json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ type JSONFeed struct {
103103
Favicon string `json:"favicon,omitempty"`
104104
Author *JSONAuthor `json:"author,omitempty"`
105105
Expired *bool `json:"expired,omitempty"`
106-
Hubs []*JSONItem `json:"hubs,omitempty"`
106+
Hubs []*JSONHub `json:"hubs,omitempty"`
107107
Items []*JSONItem `json:"items,omitempty"`
108108
}
109109

0 commit comments

Comments
 (0)