-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodes_test.go
83 lines (64 loc) · 2.95 KB
/
codes_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
72
73
74
75
76
77
78
79
80
81
82
83
package hacknews
import (
"testing"
)
func TestGetCodesTopStories(t *testing.T) {
init := Initializer{"topstories", 40}
codes, err := init.GetCodesStory()
if err != nil {
t.Error("[TestGetCodesTopStories] Expected error to be nil, got : ", err)
}
if codes == nil || len(codes) == 0 || len(codes) <= init.NbPosts || cap(codes) == 0 {
t.Error("[TestGetCodesTopStories] Expected codes to be not nil or have a length > 0 and atleast > to the number of posts asked or capacity > 0, got : ", codes, len(codes), cap(codes))
}
}
func TestGetCodeNewStories(t *testing.T) {
init := Initializer{"newstories", 30}
codes, err := init.GetCodesStory()
if err != nil {
t.Error("[TestGetCodeNewStories] Expected error to be nil, got : ", err)
}
if codes == nil || len(codes) == 0 || len(codes) <= init.NbPosts || cap(codes) == 0 {
t.Error("[TestGetCodeNewStories] Expected codes to be not nil or have a length > 0 and atleast > to the number of posts asked or capacity > 0, got : ", codes, len(codes), cap(codes))
}
}
func TestGetCodesBestStories(t *testing.T) {
init := Initializer{"beststories", 20}
codes, err := init.GetCodesStory()
if err != nil {
t.Error("[TestGetCodesBestStories] Expected error to be nil, got : ", err)
}
if codes == nil || len(codes) == 0 || len(codes) <= init.NbPosts || cap(codes) == 0 {
t.Error("[TestGetCodesBestStories] Expected codes to be not nil or have a length > 0 and atleast > to the number of posts asked or capacity > 0, got : ", codes, len(codes), cap(codes))
}
}
func TestGetCodesAskStories(t *testing.T) {
init := Initializer{"askstories", 15}
codes, err := init.GetCodesStory()
if err != nil {
t.Error("[TestGetCodesAskStories] Expected error to be nil, got : ", err)
}
if codes == nil || len(codes) == 0 || len(codes) <= init.NbPosts || cap(codes) == 0 {
t.Error("[TestGetCodesAskStories] Expected codes to be not nil or have a length > 0 and atleast > to the number of posts asked or capacity > 0, got : ", codes, len(codes), cap(codes))
}
}
func TestGetCodesShowStories(t *testing.T) {
init := Initializer{"showstories", 10}
codes, err := init.GetCodesStory()
if err != nil {
t.Error("[TestGetCodesShowStories] Expected error to be nil, got : ", err)
}
if codes == nil || len(codes) == 0 || len(codes) <= init.NbPosts || cap(codes) == 0 {
t.Error("[TestGetCodesShowStories] Expected codes to be not nil or have a length > 0 and atleast > to the number of posts asked or capacity > 0, got : ", codes, len(codes), cap(codes))
}
}
func TestGetCodesJobStories(t *testing.T) {
init := Initializer{"jobstories", 5}
codes, err := init.GetCodesStory()
if err != nil {
t.Error("[TestGetCodesJobStories] Expected error to be nil, got : ", err)
}
if codes == nil || len(codes) == 0 || len(codes) <= init.NbPosts || cap(codes) == 0 {
t.Error("[TestGetCodesJobStories] Expected codes to be not nil or have a length > 0 and atleast > to the number of posts asked or capacity > 0, got : ", codes, len(codes), cap(codes))
}
}