Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix JSONFeed Hubs #74

Merged
merged 3 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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