43 lines
920 B
Go
43 lines
920 B
Go
package rssreader
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"testing"
|
|
)
|
|
|
|
func TestParse(t *testing.T) {
|
|
content, err := ioutil.ReadFile("une.xml")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
rss, err := Parse(content)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
result_dict := map[string]string{
|
|
"Title": "Le Monde.fr - Actualités et Infos en France et dans le monde",
|
|
"Description": "Le Monde.fr - 1er site d'information. Les articles du journal et toute l'actualité en continu : International, France, Société, Economie, Culture, Environnement, Blogs ...",
|
|
"Copyright": "Copyright Le Monde.fr",
|
|
"Link": "http://www.lemonde.fr/rss/une.xml",
|
|
}
|
|
|
|
if rss.Title != result_dict["Title"] {
|
|
t.Fail()
|
|
}
|
|
if rss.Description != result_dict["Description"] {
|
|
t.Fail()
|
|
}
|
|
if rss.Copyright != result_dict["Copyright"] {
|
|
t.Fail()
|
|
}
|
|
if rss.Link != result_dict["Link"] {
|
|
t.Fail()
|
|
}
|
|
|
|
if len(rss.Items) != 21 {
|
|
t.Fail()
|
|
}
|
|
}
|