Beispiel #1
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)

}
Beispiel #2
0
func NewFeedFromSeed(seed Seed) (feed *Feed, err error) {

	// We disable caching because the first parsing is going to be discarded
	caching := rss.CacheParsedItemIDs(false)

	if seed.Username != "" && seed.Password != "" {
		feed, err = NewAuthFeed(seed.Url, seed.Username, seed.Password)
	} else {
		feed, err = NewFeed(seed.Url)
	}

	if err != nil {
		return nil, err
	}

	feed.Clear()

	feed.Seen = seed.Seen
	feed.feed.ItemMap = make(map[string]struct{})
	for _, el := range seed.Seen {
		feed.feed.ItemMap[el] = struct{}{}
	}

	rss.CacheParsedItemIDs(caching)

	return feed, nil

}
Beispiel #3
0
func TestMain(m *testing.M) {
	rss.CacheParsedItemIDs(false)
	counter = 0
	go startServer()
	os.Exit(m.Run())
}