mirror of
https://github.com/nkanaev/yarr.git
synced 2025-11-09 02:49:37 +00:00
reorganizing server-related packages
This commit is contained in:
58
src/server/opml/read_test.go
Normal file
58
src/server/opml/read_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package opml
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
have, _ := Parse(strings.NewReader(`
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<opml version="1.1">
|
||||
<head><title>Subscriptions</title></head>
|
||||
<body>
|
||||
<outline text="sub">
|
||||
<outline type="rss" text="subtitle1" description="sub1"
|
||||
xmlUrl="https://foo.com/feed.xml" htmlUrl="https://foo.com/"/>
|
||||
<outline type="rss" text="&>" description="<>"
|
||||
xmlUrl="https://bar.com/feed.xml" htmlUrl="https://bar.com/"/>
|
||||
</outline>
|
||||
<outline type="rss" text="title1" description="desc1"
|
||||
xmlUrl="https://baz.com/feed.xml" htmlUrl="https://baz.com/"/>
|
||||
</body>
|
||||
</opml>
|
||||
`))
|
||||
want := Folder{
|
||||
Title: "",
|
||||
Feeds: []Feed{
|
||||
{
|
||||
Title: "title1",
|
||||
FeedUrl: "https://baz.com/feed.xml",
|
||||
SiteUrl: "https://baz.com/",
|
||||
},
|
||||
},
|
||||
Folders: []Folder{
|
||||
{
|
||||
Title: "sub",
|
||||
Feeds: []Feed{
|
||||
{
|
||||
Title: "subtitle1",
|
||||
FeedUrl: "https://foo.com/feed.xml",
|
||||
SiteUrl: "https://foo.com/",
|
||||
},
|
||||
{
|
||||
Title: "&>",
|
||||
FeedUrl: "https://bar.com/feed.xml",
|
||||
SiteUrl: "https://bar.com/",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(want, have) {
|
||||
t.Logf("want: %#v", want)
|
||||
t.Logf("have: %#v", have)
|
||||
t.Fatal("invalid opml")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user