-
Notifications
You must be signed in to change notification settings - Fork 1
/
reddit_test.go
44 lines (34 loc) · 1.14 KB
/
reddit_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
package opinions
import (
"context"
"fmt"
"os"
"github.com/macie/opinions/internal/ensure"
"github.com/macie/opinions/internal/http"
)
func ExampleSearchReddit() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
// GitHub CI is banned by Reddit API
fmt.Println("Reddit https://reddit.com/r/softwaretesting/comments/1ef744p/the_grug_brained_developer_on_testing/ The Grug Brained Developer On Testing https://grugbrain.dev/#grug-on-testing")
return
}
client := http.Client{}
query := "https://grugbrain.dev/"
opinions := ensure.MustReturn(SearchReddit(context.TODO(), client, query))
fmt.Println(opinions[0])
// Output:
// Reddit https://reddit.com/r/softwaretesting/comments/1ef744p/the_grug_brained_developer_on_testing/ The Grug Brained Developer On Testing https://grugbrain.dev/#grug-on-testing
}
func ExampleSearchReddit_unknown() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
// GitHub CI is banned by Reddit API
fmt.Println("0")
return
}
client := http.Client{}
query := "https://invalid.domain/query"
opinions := ensure.MustReturn(SearchReddit(context.TODO(), client, query))
fmt.Println(len(opinions))
// Output:
// 0
}