-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
71 lines (63 loc) · 1.23 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestGetRecommendations(t *testing.T) {
initConfig()
ch := make(chan *Media)
path := "https://book.douban.com/subject/36481438/?icn=index-latestbook-subject"
go getMediaInfo(path, ch)
media := <-ch
close(ch)
fmt.Printf("%+v\n", media.OriginalMedia)
for _, m := range media.RecommendedMedias {
fmt.Printf("%+v\n", m)
}
}
func TestPrepareMediaLinks(t *testing.T) {
initConfig()
prepareMediaLinks()
}
func TestGetAllRecommendations(t *testing.T) {
initConfig()
links := []string{
"https://movie.douban.com/subject/1292063/",
"https://movie.douban.com/subject/1292052/",
}
getMedias(links)
}
func TestGetPersonalMark(t *testing.T) {
initConfig()
ch := make(chan []string)
go getPersonalMarkMediaLinks(1, ch)
fmt.Println(<-ch)
close(ch)
}
func TestGetPersonalMarkMediaTotal(t *testing.T) {
initConfig()
fmt.Println(getPersonalMarkMediaTotal())
}
func TestGetMaxStart(t *testing.T) {
tests := []struct {
input int
expect int
}{
{
input: 10,
expect: 0,
},
{
input: 45,
expect: 30,
},
{
input: 90,
expect: 60,
},
}
for _, tt := range tests {
require.Equal(t, tt.expect, getMaxStart(tt.input))
}
}