@@ -3,10 +3,11 @@ package habr
3
3
import (
4
4
"testing"
5
5
6
+ "github.com/mmcdole/gofeed"
6
7
"github.com/stretchr/testify/assert"
7
8
)
8
9
9
- func TestStripTags_PositiveCases (t * testing.T ) {
10
+ func Test_StripTags_PositiveCases (t * testing.T ) {
10
11
tests := []struct {
11
12
input string
12
13
expectedOutput string
@@ -44,13 +45,25 @@ func TestStripTags_PositiveCases(t *testing.T) {
44
45
}
45
46
}
46
47
47
- func TestGetPostID (t * testing.T ) {
48
+ func Test_GetPostID (t * testing.T ) {
48
49
input := `https://habr.com/post/413925/?utm_source=habrahabr&utm_medium=rss&utm_campaign=413925`
49
50
outputExpected := "413925"
50
51
outputActual := getPostID (input )
51
52
assert .Equal (t , outputExpected , outputActual )
52
53
}
53
54
55
+ func Test_ProcessItem (t * testing.T ) {
56
+ item := gofeed.Item {
57
+ Title : "стекло & пиксел" ,
58
+ Description : "description" ,
59
+ Link : "http://habr.com/post/1/" ,
60
+ }
61
+ feedItem , err := processItem (& item )
62
+ assert .Nil (t , err )
63
+ assert .Equal (t , "1" , feedItem .ID )
64
+ assert .Equal (t , `<a href="http://habr.com/post/1/">` + "стекло & пиксел" + `</a>` + "\n description" , feedItem .Message )
65
+ }
66
+
54
67
// func TestManual(t *testing.T) {
55
68
// c := NewHabrReader()
56
69
// feeds := c.GetBestFeed()
0 commit comments