-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathsearch_test.go
51 lines (38 loc) · 990 Bytes
/
search_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
// Copyright 2020-21 PJ Engineering and Business Solutions Pty. Ltd. All rights reserved.
package googlesearch_test
import (
"testing"
googlesearch "github.com/rocketlaunchr/google-search"
)
func TestSearch(t *testing.T) {
q := "Hello World"
opts := googlesearch.SearchOptions{
Limit: 20,
}
//lint:ignore SA1012 ignore this bare essentials by passing nil for context and removing context package (despite not being idiomatic go).
returnLinks, err := googlesearch.Search(nil, q, opts)
if err != nil {
t.Errorf("something went wrong: %v", err)
return
}
if len(returnLinks) == 0 {
t.Errorf("no results returned: %v", returnLinks)
}
noURL := 0
noTitle := 0
noDesc := 0
for _, res := range returnLinks {
if res.URL == "" {
noURL++
}
if res.Title == "" {
noTitle++
}
if res.Description == "" {
noDesc++
}
}
if noURL == len(returnLinks) || noTitle == len(returnLinks) || noDesc == len(returnLinks) {
t.Errorf("google dom changed")
}
}