-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_test.go
51 lines (45 loc) · 948 Bytes
/
stack_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
package GoStack
import "testing"
func TestGetComments(t *testing.T) {
comments, err := GetComments("stackoverflow")
if err != nil {
t.Log(err.Error())
} else {
t.Log(len(comments))
if len(comments) == 0 {
t.Fatal("No Http error, but failed to read comments")
}
}
}
func TestGetAnswers(t *testing.T) {
questions, err := GetQuestions("stackoverflow")
if err != nil {
t.Log(err.Error())
}
if len(questions) > 0 {
answers, err := questions[0].GetAnswers()
if err != nil {
t.Log(err.Error())
}
println(answers)
}
}
func TestGetPosts(t *testing.T) {
posts, err := GetPosts("stackoverflow")
if err != nil {
t.Log(err.Error())
} else {
if len(posts) == 0 {
t.Fatal("No HTTP error, but no posts")
}
}
}
func TestAuthentication(t *testing.T) {
token, err := GetAccessToken("10737", "40SqxdGUyX01sxjH2UVwJw((")
if err == nil {
if token == "" {
t.Log(token)
t.Fatal("Couldn't find token")
}
}
}