1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-02 16:38:37 +00:00

Improve OPML import/export

This commit is contained in:
Frédéric Guillot 2017-11-20 14:35:11 -08:00
parent ace7524905
commit a76c2a8c22
15 changed files with 51 additions and 31 deletions

View file

@ -4,8 +4,11 @@
package opml
import "testing"
import "bytes"
import (
"bytes"
"fmt"
"testing"
)
func TestSerialize(t *testing.T) {
var subscriptions SubcriptionList
@ -14,6 +17,7 @@ func TestSerialize(t *testing.T) {
subscriptions = append(subscriptions, &Subcription{Title: "Feed 3", FeedURL: "http://example.org/feed/3", SiteURL: "http://example.org/3", CategoryName: "Category 2"})
output := Serialize(subscriptions)
fmt.Println(output)
feeds, err := Parse(bytes.NewBufferString(output))
if err != nil {
t.Error(err)
@ -23,9 +27,16 @@ func TestSerialize(t *testing.T) {
t.Errorf("Wrong number of subscriptions: %d instead of %d", len(feeds), 3)
}
for i := 0; i < len(feeds); i++ {
if !feeds[i].Equals(subscriptions[i]) {
t.Errorf(`Subscription are different: "%v" vs "%v"`, subscriptions[i], feeds[i])
found := false
for _, feed := range feeds {
if feed.Title == "Feed 1" && feed.CategoryName == "Category 1" &&
feed.FeedURL == "http://example.org/feed/1" && feed.SiteURL == "http://example.org/1" {
found = true
break
}
}
if !found {
t.Error("Serialized feed is incorrect")
}
}