Initial rss with partially tested items

This commit is contained in:
Bel LaPointe
2018-10-07 23:06:21 -06:00
parent cfb31cf6a5
commit eeb577dda8
3 changed files with 238 additions and 0 deletions

61
rss/item_test.go Normal file
View File

@@ -0,0 +1,61 @@
package rss
import (
"testing"
"github.com/mmcdole/gofeed"
)
func Test_RSSItem(t *testing.T) {
cases := []struct {
input gofeed.Item
filter string
output Item
}{
{
input: gofeed.Item{
Title: "a",
Link: "b",
Content: "",
},
filter: "",
output: Item{
Name: "a",
Link: "b",
Content: "",
},
},
{
input: gofeed.Item{
Title: "a",
Link: "b",
Content: `x y <img src="asdf"></img>`,
},
filter: "[a-z]*",
output: Item{
Name: "a",
Link: "b",
Content: "x\n<br>\ny",
},
},
{
input: gofeed.Item{
Title: "a",
Link: "b",
Content: "x y",
},
filter: "[a-z]*",
output: Item{
Name: "a",
Link: "b",
Content: "x\n<br>\ny",
},
},
}
for _, c := range cases {
output := fromGofeedItem(&c.input, c.filter)
if *output != c.output {
t.Errorf("failed to convert gofeed: wanted %v, got %v", c.output, *output)
}
}
}