rss/bbclearn/bbc_test.go

95 lines
1.8 KiB
Go
Raw Normal View History

2023-04-13 18:03:56 +00:00
package bbclearn
import (
"github.com/PuerkitoBio/goquery"
"github.com/fthvgb1/wp-go/rss2"
"os"
"reflect"
"strings"
"testing"
)
func Test_full(t *testing.T) {
type args struct {
doc *goquery.Document
recentDay int
}
tests := []struct {
name string
args args
want rss2.Item
}{
{
name: "t1",
args: args{doc: func() *goquery.Document {
f, _ := os.ReadFile("b.html")
d, _ := goquery.NewDocumentFromReader(strings.NewReader(string(f)))
return d
}(), recentDay: 1},
//want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := full(tt.args.doc, tt.args.recentDay); got != tt.want {
t.Errorf("full() = %v, want %v", got, tt.want)
}
})
}
}
func Test_items(t *testing.T) {
type args struct {
doc *goquery.Document
recentDay int
}
tests := []struct {
name string
args args
wantR rss2.Item
}{
{
name: "t1",
args: args{
doc: func() *goquery.Document {
f, _ := os.ReadFile("b.html")
d, _ := goquery.NewDocumentFromReader(strings.NewReader(string(f)))
return d
}(),
recentDay: 1,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotR := items(tt.args.doc, tt.args.recentDay); !reflect.DeepEqual(gotR, tt.wantR) {
t.Errorf("items() = %v, want %v", gotR, tt.wantR)
}
})
}
}
2023-07-09 14:57:47 +00:00
func Test_fetch(t *testing.T) {
type args struct {
u string
}
tests := []struct {
name string
args args
wantR rss2.Item
}{
{
name: "t1",
args: args{u: "https://www.bbc.co.uk/learningenglish/chinese/features/take-away-english/ep-230703"},
wantR: rss2.Item{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotR := fetch(tt.args.u); !reflect.DeepEqual(gotR, tt.wantR) {
t.Errorf("fetch() = %v, want %v", gotR, tt.wantR)
}
})
}
}