You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
616 B
Go
37 lines
616 B
Go
5 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"hugobot/handlers"
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
rssTestFeed = "https://bitcointechweekly.com/index.xml"
|
||
|
rssTestFeed2 = "https://bitcoinops.org/feed.xml"
|
||
|
)
|
||
|
|
||
|
func TestFetch(t *testing.T) {
|
||
|
handler := handlers.NewRSSHandler()
|
||
|
when, _ := time.Parse("Jan 2006", "Jun 2018")
|
||
|
res, err := handler.FetchSince(rssTestFeed2, when)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
|
||
|
for i, post := range res {
|
||
|
f, err := os.Create(fmt.Sprintf("%d.html", i))
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
defer f.Close()
|
||
|
_, err = f.WriteString(post.Content)
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|