71 lines
1.3 KiB
Go
71 lines
1.3 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|