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 = "-"
intitleTag = "intitle:"
intextTag = "intext:"
operatorOr = "|"
operatorAnd = "+"
)
// 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
func (e *GoogleSearch) Or() *GoogleSearch {
e.tags = append(e.tags, "OR")
e.tags = append(e.tags, operatorOr)
return e
}

View File

@ -123,7 +123,7 @@ func TestInit(t *testing.T) {
Site("twitter.com").
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) {
@ -134,7 +134,7 @@ func TestInit(t *testing.T) {
Group((NewGoogleSearch()).Intext("1").Or().Intext("2")).
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) {
@ -146,7 +146,7 @@ func TestInit(t *testing.T) {
Intitle("jordan").
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) {
@ -159,7 +159,7 @@ func TestInit(t *testing.T) {
QueryValues()
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")
})
}