Initial rss with partially tested items
This commit is contained in:
61
rss/item_test.go
Normal file
61
rss/item_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user