Exemplo n.º 1
0
func TestFeed(t *testing.T) {

	_, err := feeder.NewFeed("http://localhost:3000/auth/hn")
	if err != nil && err.Error() != "HTTP Error. Status Code 401" {
		t.Error("Error badly handeled")
	}

	_, err = feeder.NewAuthFeed("http://localhost:3000/auth/hn", "username", "password")
	if err != nil && err.Error() != "Impossible to parse Feed. EOF" {
		t.Error("Auth not working.", err)
	}

	feed, err := feeder.NewFeed("http://localhost:3000/hn")
	if err != nil {
		t.Error(err)
	}

	if feed.Url != "http://localhost:3000/hn" ||
		feed.Status != feeder.StatusOK ||
		feed.Name != "Hacker News" {

		t.Log(feed)
		t.Error("Error during Feed Init")

	}

}
Exemplo n.º 2
0
func TestSeed(t *testing.T) {

	rss.CacheParsedItemIDs(true)

	feed, err := feeder.NewAuthFeed("http://localhost:3000/auth/hn", "username", "password")
	if err != nil {
		t.Error(err)
	}

	feed.ReadNew()
	seed := feed.ExportSeed()

	feedA, err := feeder.NewFeedFromSeed(seed)
	if err != nil {
		t.Error(err)
	}

	sub := new(feeder.TestSubscriber)
	feedA.Register(sub)

	feedA.Update(true)
	feedA.Update(true)

	if len(sub.Items) != 20 {
		t.Error("History export Not working", len(sub.Items))
	}

	rss.CacheParsedItemIDs(false)

}