-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplore_test.go
67 lines (56 loc) · 1.33 KB
/
explore_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
package explore_test
import (
"fmt"
"github.com/high5/go-qiita-explore"
"log"
)
func ExampleExplore_GetStocks() {
explore := explore.NewExplore()
mainTag := "Ruby"
articles, err := explore.GetStocks(mainTag)
if err != nil {
log.Fatal(err)
}
existsTag := true
for _, article := range articles {
for _, tag := range article.Tags {
if tag != mainTag {
existsTag = false
} else {
existsTag = true
break
}
}
}
if len(articles) > 0 && existsTag == true {
fmt.Println("Articles (filtered by Ruby) recieved.")
} else {
fmt.Printf("Number of articles recieved: %d (filtered by Ruby %v)", len(articles), existsTag)
}
// Output: Articles (filtered by Ruby) recieved.
}
func ExampleExplore_GetItems() {
explore := explore.NewExplore()
mainTag := "JavaScript"
articles, err := explore.GetItems(mainTag, 1)
if err != nil {
log.Fatal(err)
}
existsTag := true
for _, article := range articles {
for _, tag := range article.Tags {
if tag != mainTag {
existsTag = false
} else {
existsTag = true
break
}
}
}
if len(articles) > 0 && existsTag == true {
fmt.Println("Articles (filtered by JavaScript) recieved.")
} else {
fmt.Printf("Number of articles recieved: %d (filtered by JavaScript %v)", len(articles), existsTag)
}
// Output: Articles (filtered by JavaScript) recieved.
}