File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -481,3 +481,34 @@ func TestFeedSorted(t *testing.T) {
481
481
t .Errorf ("JSON not what was expected. Got:\n ||%s||\n \n Expected:\n ||%s||\n " , got , jsonOutputSorted )
482
482
}
483
483
}
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 \n Expected:\n %s\n " , json , jsonOutputHub )
513
+ }
514
+ }
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ type JSONFeed struct {
103
103
Favicon string `json:"favicon,omitempty"`
104
104
Author * JSONAuthor `json:"author,omitempty"`
105
105
Expired * bool `json:"expired,omitempty"`
106
- Hubs []* JSONItem `json:"hubs,omitempty"`
106
+ Hubs []* JSONHub `json:"hubs,omitempty"`
107
107
Items []* JSONItem `json:"items,omitempty"`
108
108
}
109
109
You can’t perform that action at this time.
0 commit comments