diff options
author | Frédéric Guillot <fred@miniflux.net> | 2017-11-19 21:10:04 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2017-11-19 22:01:46 -0800 |
commit | 8ffb773f43c8dc54801ca1d111854e7e881c93c9 (patch) | |
tree | 38133a2fc612597a75fed1d13e5b4042f58a2b7e /reader/opml/serializer_test.go |
First commit
Diffstat (limited to 'reader/opml/serializer_test.go')
-rw-r--r-- | reader/opml/serializer_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/reader/opml/serializer_test.go b/reader/opml/serializer_test.go new file mode 100644 index 0000000..b1ef2a6 --- /dev/null +++ b/reader/opml/serializer_test.go @@ -0,0 +1,31 @@ +// Copyright 2017 Frédéric Guillot. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package opml + +import "testing" +import "bytes" + +func TestSerialize(t *testing.T) { + var subscriptions SubcriptionList + subscriptions = append(subscriptions, &Subcription{Title: "Feed 1", FeedURL: "http://example.org/feed/1", SiteURL: "http://example.org/1", CategoryName: "Category 1"}) + subscriptions = append(subscriptions, &Subcription{Title: "Feed 2", FeedURL: "http://example.org/feed/2", SiteURL: "http://example.org/2", CategoryName: "Category 1"}) + subscriptions = append(subscriptions, &Subcription{Title: "Feed 3", FeedURL: "http://example.org/feed/3", SiteURL: "http://example.org/3", CategoryName: "Category 2"}) + + output := Serialize(subscriptions) + feeds, err := Parse(bytes.NewBufferString(output)) + if err != nil { + t.Error(err) + } + + if len(feeds) != 3 { + 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]) + } + } +} |