From 9a82cd97af221ee23ecfe8705372ecac5d1fe104 Mon Sep 17 00:00:00 2001 From: davy Date: Sun, 21 Jul 2019 10:56:11 -0500 Subject: [PATCH 1/3] fix JSONFeed Hubs --- json.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json.go b/json.go index 75a82fd..0302c22 100644 --- a/json.go +++ b/json.go @@ -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"` } From b194c17a5c1dde096d02686d2a67e85c7b7d685c Mon Sep 17 00:00:00 2001 From: davy Date: Thu, 25 Jul 2019 10:29:58 -0500 Subject: [PATCH 2/3] Add JSONHub test --- feed_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/feed_test.go b/feed_test.go index ecc036b..f665585 100644 --- a/feed_test.go +++ b/feed_test.go @@ -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, jsonOutputSorted) + } +} From a65d70099a5aa71af43edc0ad80206f086fe9962 Mon Sep 17 00:00:00 2001 From: davy Date: Thu, 25 Jul 2019 10:55:49 -0500 Subject: [PATCH 3/3] fixed test output --- feed_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feed_test.go b/feed_test.go index f665585..7493bf1 100644 --- a/feed_test.go +++ b/feed_test.go @@ -509,6 +509,6 @@ func TestJSONHub(t *testing.T) { 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, jsonOutputSorted) + t.Errorf("JSON not what was expected. Got:\n%s\n\nExpected:\n%s\n", json, jsonOutputHub) } }