forked from paymydrink/go-yelp-fusion
Porting golang yelp wrapper to v3-fusion-api
This commit is contained in:
89
yelp/general_options_test.go
Normal file
89
yelp/general_options_test.go
Normal file
@@ -0,0 +1,89 @@
|
||||
package yelp
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/guregu/null"
|
||||
)
|
||||
|
||||
// TestGeneralOptions will verify search with location and search term.
|
||||
func TestGeneralOptions(t *testing.T) {
|
||||
client := getClient(t)
|
||||
options := SearchOptions{
|
||||
GeneralOptions: &GeneralOptions{
|
||||
Term: "coffee",
|
||||
},
|
||||
LocationOptions: &LocationOptions{
|
||||
Location: "seattle",
|
||||
},
|
||||
}
|
||||
result, err := client.DoSearch(options)
|
||||
check(t, err)
|
||||
assert(t, len(result.Businesses) > 0, containsResults)
|
||||
}
|
||||
|
||||
// TestUnescapedCharactersInGeneralOptions verify URL escaped characters do not cause search to fail.
|
||||
func TestUnescapedCharactersInGeneralOptions(t *testing.T) {
|
||||
client := getClient(t)
|
||||
options := SearchOptions{
|
||||
GeneralOptions: &GeneralOptions{
|
||||
Term: "Frimark Keller & Associates",
|
||||
},
|
||||
LocationOptions: &LocationOptions{
|
||||
Location: "60173",
|
||||
},
|
||||
}
|
||||
result, err := client.DoSearch(options)
|
||||
check(t, err)
|
||||
assert(t, len(result.Businesses) > 0, containsResults)
|
||||
}
|
||||
|
||||
// TestMultipleCategories will perform a search with multiple categories on the general options filter.
|
||||
func TestMultipleCategories(t *testing.T) {
|
||||
client := getClient(t)
|
||||
options := SearchOptions{
|
||||
GeneralOptions: &GeneralOptions{
|
||||
CategoryFilter: "climbing,bowling",
|
||||
},
|
||||
LocationOptions: &LocationOptions{
|
||||
Location: "Seattle",
|
||||
},
|
||||
}
|
||||
result, err := client.DoSearch(options)
|
||||
check(t, err)
|
||||
assert(t, len(result.Businesses) > 0, containsResults)
|
||||
}
|
||||
|
||||
// TestLimit verify the limit parameter works as expected.
|
||||
func TestLimit(t *testing.T) {
|
||||
client := getClient(t)
|
||||
options := SearchOptions{
|
||||
GeneralOptions: &GeneralOptions{
|
||||
Term: "Coffee",
|
||||
Limit: null.IntFrom(15),
|
||||
},
|
||||
LocationOptions: &LocationOptions{
|
||||
Location: "Seattle",
|
||||
},
|
||||
}
|
||||
result, err := client.DoSearch(options)
|
||||
check(t, err)
|
||||
assert(t, len(result.Businesses) == 15, "There should be 15 results.")
|
||||
}
|
||||
|
||||
// TestLocaleOptions will verify doing a search that includes locale options.
|
||||
func TestLocaleOptions(t *testing.T) {
|
||||
client := getClient(t)
|
||||
options := SearchOptions{
|
||||
GeneralOptions: &GeneralOptions{
|
||||
Term: "coffee",
|
||||
Locale: "en_US",
|
||||
},
|
||||
LocationOptions: &LocationOptions{
|
||||
Location: "seattle",
|
||||
},
|
||||
}
|
||||
result, err := client.DoSearch(options)
|
||||
check(t, err)
|
||||
assert(t, len(result.Businesses) > 0, containsResults)
|
||||
}
|
||||
Reference in New Issue
Block a user