feat: create And method
parent
9da2506700
commit
981b9721ed
|
@ -65,6 +65,12 @@ func (e *GoogleSearch) Or() *GoogleSearch {
|
|||
return e
|
||||
}
|
||||
|
||||
// And puts an AND operator in the request
|
||||
func (e *GoogleSearch) And() *GoogleSearch {
|
||||
e.tags = append(e.tags, operatorAnd)
|
||||
return e
|
||||
}
|
||||
|
||||
// Intext searches for the occurrences of keywords all at once or one at a time.
|
||||
func (e *GoogleSearch) Intext(text string) *GoogleSearch {
|
||||
e.tags = append(e.tags, e.concat(intextTag, text, true))
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestInit(t *testing.T) {
|
|||
assert.Equal(result, "-html -htm -php -md5sums", "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should handle or tag correctly", func(t *testing.T) {
|
||||
t.Run("should handle 'OR' tag correctly", func(t *testing.T) {
|
||||
dork = NewGoogleSearch()
|
||||
|
||||
result := dork.
|
||||
|
@ -126,6 +126,18 @@ func TestInit(t *testing.T) {
|
|||
assert.Equal(result, "site:facebook.com | site:twitter.com", "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should handle 'AND' tag correctly", func(t *testing.T) {
|
||||
dork = NewGoogleSearch()
|
||||
|
||||
result := dork.
|
||||
Intitle("facebook").
|
||||
And().
|
||||
Intitle("twitter").
|
||||
String()
|
||||
|
||||
assert.Equal(result, "intitle:\"facebook\" + intitle:\"twitter\"", "they should be equal")
|
||||
})
|
||||
|
||||
t.Run("should handle group tag correctly", func(t *testing.T) {
|
||||
dork = NewGoogleSearch()
|
||||
|
||||
|
|
Loading…
Reference in New Issue