@@ -8,118 +8,134 @@ import (
88
99var dork * GoogleSearch
1010
11- func TestToUrl (t * testing.T ) {
12- dork = & GoogleSearch {}
11+ func TestInit (t * testing.T ) {
12+ assert := assert . New ( t )
1313
14- result := dork .
15- Site ("example.com" ).
16- ToURL ()
14+ t .Run ("should convert to URL correctly" , func (t * testing.T ) {
15+ dork = & GoogleSearch {}
1716
18- assert .Equal (t , result , "https://www.google.com/search?q=site%3Aexample.com" , "they should be equal" )
19- }
17+ result := dork .
18+ Site ("example.com" ).
19+ ToURL ()
2020
21- func TestSite ( t * testing. T ) {
22- dork = & GoogleSearch {}
21+ assert . Equal ( result , "https://www.google.com/search?q=site%3Aexample.com" , "they should be equal" )
22+ })
2323
24- result := dork .
25- Site ("example.com" ).
26- ToString ()
24+ t .Run ("should handle site tag correctly" , func (t * testing.T ) {
25+ dork = & GoogleSearch {}
2726
28- assert .Equal (t , result , "site:example.com" , "they should be equal" )
29- }
27+ result := dork .
28+ Site ("example.com" ).
29+ ToString ()
3030
31- func TestIntext ( t * testing. T ) {
32- dork = & GoogleSearch {}
31+ assert . Equal ( result , "site:example.com" , "they should be equal" )
32+ })
3333
34- result := dork .
35- Intext ("text" ).
36- ToString ()
34+ t .Run ("should handle intext tag correctly" , func (t * testing.T ) {
35+ dork = & GoogleSearch {}
3736
38- assert .Equal (t , result , "\" text\" " , "they should be equal" )
39- }
37+ result := dork .
38+ Intext ("text" ).
39+ ToString ()
4040
41- func TestInurl ( t * testing. T ) {
42- dork = & GoogleSearch {}
41+ assert . Equal ( result , " \" text \" " , "they should be equal" )
42+ })
4343
44- result := dork .
45- Inurl ("index.php" ).
46- ToString ()
44+ t .Run ("should handle inurl tag correctly" , func (t * testing.T ) {
45+ dork = & GoogleSearch {}
4746
48- assert .Equal (t , result , "inurl:\" index.php\" " , "they should be equal" )
49- }
47+ result := dork .
48+ Inurl ("index.php" ).
49+ ToString ()
5050
51- func TestFiletype ( t * testing. T ) {
52- dork = & GoogleSearch {}
51+ assert . Equal ( result , "inurl: \" index.php \" " , "they should be equal" )
52+ })
5353
54- result := dork .
55- Filetype ("pdf" ).
56- ToString ()
54+ t .Run ("should handle rrrrr tag correctly" , func (t * testing.T ) {
55+ dork = & GoogleSearch {}
5756
58- assert .Equal (t , result , "filetype:\" pdf\" " , "they should be equal" )
59- }
57+ result := dork .
58+ Filetype ("pdf" ).
59+ ToString ()
6060
61- func TestCache ( t * testing. T ) {
62- dork = & GoogleSearch {}
61+ assert . Equal ( result , "filetype: \" pdf \" " , "they should be equal" )
62+ })
6363
64- result := dork .
65- Cache ("www.google.com" ).
66- ToString ()
64+ t .Run ("should handle cache tag correctly" , func (t * testing.T ) {
65+ dork = & GoogleSearch {}
6766
68- assert .Equal (t , result , "cache:\" www.google.com\" " , "they should be equal" )
69- }
67+ result := dork .
68+ Cache ("www.google.com" ).
69+ ToString ()
7070
71- func TestRelated ( t * testing. T ) {
72- dork = & GoogleSearch {}
71+ assert . Equal ( result , "cache: \" www.google.com \" " , "they should be equal" )
72+ })
7373
74- result := dork .
75- Related ("www.google.com" ).
76- ToString ()
74+ t .Run ("should handle related tag correctly" , func (t * testing.T ) {
75+ dork = & GoogleSearch {}
7776
78- assert .Equal (t , result , "related:\" www.google.com\" " , "they should be equal" )
79- }
77+ result := dork .
78+ Related ("www.google.com" ).
79+ ToString ()
8080
81- func TestExt ( t * testing. T ) {
82- dork = & GoogleSearch {}
81+ assert . Equal ( result , "related: \" www.google.com \" " , "they should be equal" )
82+ })
8383
84- result := dork .
85- Ext ("(doc | pdf | xls | txt | xml)" ).
86- ToString ()
84+ t .Run ("should handle ext tag correctly" , func (t * testing.T ) {
85+ dork = & GoogleSearch {}
8786
88- assert .Equal (t , result , "ext:(doc | pdf | xls | txt | xml)" , "they should be equal" )
89- }
87+ result := dork .
88+ Ext ("(doc | pdf | xls | txt | xml)" ).
89+ ToString ()
9090
91- func TestExclude ( t * testing. T ) {
92- dork = & GoogleSearch {}
91+ assert . Equal ( result , "ext:(doc | pdf | xls | txt | xml)" , "they should be equal" )
92+ })
9393
94- result := dork .
95- Exclude ("html" ).
96- Exclude ("htm" ).
97- Exclude ("php" ).
98- Exclude ("md5sums" ).
99- ToString ()
94+ t .Run ("should handle exclude tag correctly" , func (t * testing.T ) {
95+ dork = & GoogleSearch {}
10096
101- assert .Equal (t , result , "-html -htm -php -md5sums" , "they should be equal" )
102- }
97+ result := dork .
98+ Exclude ("html" ).
99+ Exclude ("htm" ).
100+ Exclude ("php" ).
101+ Exclude ("md5sums" ).
102+ ToString ()
103103
104- func TestOr ( t * testing. T ) {
105- dork = & GoogleSearch {}
104+ assert . Equal ( result , "-html -htm -php -md5sums" , "they should be equal" )
105+ })
106106
107- result := dork .
108- Site ("facebook.com" ).
109- Or ().
110- Site ("twitter.com" ).
111- ToString ()
107+ t .Run ("should handle or tag correctly" , func (t * testing.T ) {
108+ dork = & GoogleSearch {}
112109
113- assert .Equal (t , result , "site:facebook.com OR site:twitter.com" , "they should be equal" )
114- }
110+ result := dork .
111+ Site ("facebook.com" ).
112+ Or ().
113+ Site ("twitter.com" ).
114+ ToString ()
115+
116+ assert .Equal (result , "site:facebook.com OR site:twitter.com" , "they should be equal" )
117+ })
118+
119+ t .Run ("should handle group tag correctly" , func (t * testing.T ) {
120+ dork = & GoogleSearch {}
121+
122+ result := dork .
123+ Site ("linkedin.com" ).
124+ Group ((& GoogleSearch {}).Intext ("1" ).Or ().Intext ("2" ).ToString ()).
125+ ToString ()
126+
127+ assert .Equal (result , "site:linkedin.com (\" 1\" OR \" 2\" )" , "they should be equal" )
128+ })
115129
116- func TestGroup (t * testing.T ) {
117- dork = & GoogleSearch {}
130+ t . Run ( "should handle rrrrr tag correctly" , func (t * testing.T ) {
131+ dork = & GoogleSearch {}
118132
119- result := dork .
120- Site ("linkedin.com" ).
121- Group ((& GoogleSearch {}).Intext ("1" ).Or ().Intext ("2" ).ToString ()).
122- ToString ()
133+ result := dork .
134+ Site ("linkedin.com" ).
135+ Group ((& GoogleSearch {}).Intext ("1" ).Or ().Intext ("2" ).ToString ()).
136+ Intitle ("jordan" ).
137+ ToString ()
123138
124- assert .Equal (t , result , "site:linkedin.com (\" 1\" OR \" 2\" )" , "they should be equal" )
139+ assert .Equal (result , "site:linkedin.com (\" 1\" OR \" 2\" ) intitle:\" jordan\" " , "they should be equal" )
140+ })
125141}
0 commit comments