refactor: change OR operator value to |

pull/12/head
sundowndev 2020-09-05 16:51:45 +02:00
parent 8aa349a3e3
commit 9da2506700
2 changed files with 7 additions and 5 deletions

View File

@ -16,6 +16,8 @@ const (
excludeTag = "-" excludeTag = "-"
intitleTag = "intitle:" intitleTag = "intitle:"
intextTag = "intext:" intextTag = "intext:"
operatorOr = "|"
operatorAnd = "+"
) )
// GoogleSearch is the Google search implementation for Dorkgen // GoogleSearch is the Google search implementation for Dorkgen
@ -59,7 +61,7 @@ func (e *GoogleSearch) Site(site string) *GoogleSearch {
// Or puts an OR operator in the request // Or puts an OR operator in the request
func (e *GoogleSearch) Or() *GoogleSearch { func (e *GoogleSearch) Or() *GoogleSearch {
e.tags = append(e.tags, "OR") e.tags = append(e.tags, operatorOr)
return e return e
} }

View File

@ -123,7 +123,7 @@ func TestInit(t *testing.T) {
Site("twitter.com"). Site("twitter.com").
String() String()
assert.Equal(result, "site:facebook.com OR site:twitter.com", "they should be equal") assert.Equal(result, "site:facebook.com | site:twitter.com", "they should be equal")
}) })
t.Run("should handle group tag correctly", func(t *testing.T) { t.Run("should handle group tag correctly", func(t *testing.T) {
@ -134,7 +134,7 @@ func TestInit(t *testing.T) {
Group((NewGoogleSearch()).Intext("1").Or().Intext("2")). Group((NewGoogleSearch()).Intext("1").Or().Intext("2")).
String() String()
assert.Equal(result, "site:linkedin.com (intext:\"1\" OR intext:\"2\")", "they should be equal") assert.Equal(result, "site:linkedin.com (intext:\"1\" | intext:\"2\")", "they should be equal")
}) })
t.Run("should handle group tag correctly", func(t *testing.T) { t.Run("should handle group tag correctly", func(t *testing.T) {
@ -146,7 +146,7 @@ func TestInit(t *testing.T) {
Intitle("jordan"). Intitle("jordan").
String() String()
assert.Equal(result, "site:linkedin.com (intext:\"1\" OR intext:\"2\") intitle:\"jordan\"", "they should be equal") assert.Equal(result, "site:linkedin.com (intext:\"1\" | intext:\"2\") intitle:\"jordan\"", "they should be equal")
}) })
t.Run("should return URL values", func(t *testing.T) { t.Run("should return URL values", func(t *testing.T) {
@ -159,7 +159,7 @@ func TestInit(t *testing.T) {
QueryValues() QueryValues()
assert.Equal(url.Values{ assert.Equal(url.Values{
"q": []string{"site:linkedin.com (intext:\"1\" OR intext:\"2\") intitle:\"jordan\""}, "q": []string{"site:linkedin.com (intext:\"1\" | intext:\"2\") intitle:\"jordan\""},
}, result, "they should be equal") }, result, "they should be equal")
}) })
} }