-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opml: add newsblur test case, add fallback time formats
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
- Loading branch information
1 parent
97c8425
commit 817e827
Showing
7 changed files
with
342 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Copyright (c) VirtualTam | ||
// SPDX-License-Identifier: MIT | ||
|
||
package opml | ||
|
||
import ( | ||
"encoding/xml" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
var ( | ||
feedReaderDocumentNewsblur = Document{ | ||
XMLName: xml.Name{Local: "opml"}, | ||
Version: Version1_1, | ||
Head: Head{ | ||
Title: "NewsBlur Feeds", | ||
DateCreated: mustDecodeRFC1123Time("Thu, 07 Nov 2024 20:18:01.109756 GMT"), | ||
DateModified: mustDecodeRFC1123Time("Thu, 07 Nov 2024 20:18:01.109756 GMT"), | ||
}, | ||
Body: Body{ | ||
Outlines: []Outline{ | ||
{ | ||
Text: "Security", | ||
Title: "Security", | ||
Outlines: []Outline{ | ||
{ | ||
Text: "Google Online Security Blog", | ||
Title: "Google Online Security Blog", | ||
Type: OutlineTypeSubscription, | ||
Version: RSSVersion1, | ||
HtmlUrl: "http://security.googleblog.com/", | ||
XmlUrl: "http://www.blogger.com/feeds/1176949257541686127/posts/default?max-results=25&redirect=false&start-index=26", | ||
}, | ||
{ | ||
Text: "Blog on Library", | ||
Title: "Blog on Library", | ||
Type: OutlineTypeSubscription, | ||
Version: RSSVersion1, | ||
HtmlUrl: "https://www.openssl.org/blog/", | ||
XmlUrl: "https://openssl-library.org:443/post/atom.xml", | ||
}, | ||
{ | ||
Text: "Schneier on Security", | ||
Title: "Schneier on Security", | ||
Type: OutlineTypeSubscription, | ||
Version: RSSVersion1, | ||
HtmlUrl: "https://www.schneier.com", | ||
XmlUrl: "https://www.schneier.com/feed/atom/", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Text: "Self-Hosted", | ||
Title: "Self-Hosted", | ||
}, | ||
{ | ||
Text: "Cryptography", | ||
Title: "Cryptography", | ||
}, | ||
{ | ||
Text: "Programming", | ||
Title: "Programming", | ||
Outlines: []Outline{ | ||
{ | ||
Text: "Git Rev News", | ||
Title: "Git Rev News", | ||
Type: OutlineTypeSubscription, | ||
Version: RSSVersion1, | ||
HtmlUrl: "https://git.github.io/rev_news/", | ||
XmlUrl: "https://git.github.io/feed.xml", | ||
}, | ||
{ | ||
Text: "The Go Programming Language Blog", | ||
Title: "The Go Programming Language Blog", | ||
Type: OutlineTypeSubscription, | ||
Version: RSSVersion1, | ||
HtmlUrl: "tag:blog.golang.org,2013:blog.golang.org", | ||
XmlUrl: "https://go.dev/blog/feed.atom", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
func TestUnmarshalFeedReader(t *testing.T) { | ||
cases := []struct { | ||
tname string | ||
inputFileName string | ||
want Document | ||
}{ | ||
{ | ||
tname: "newsblur", | ||
inputFileName: "newsblur.opml", | ||
want: feedReaderDocumentNewsblur, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.tname, func(t *testing.T) { | ||
inputFilePath := filepath.Join("testdata", "feedreader", tc.inputFileName) | ||
|
||
got, err := UnmarshalFile(inputFilePath) | ||
if err != nil { | ||
t.Fatalf("want no error, got %q", err) | ||
} | ||
|
||
assertDocumentsEqual(t, *got, tc.want) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.