0
0
Fork 0

removing mock data generation packages from unit-tests

fixing wrong sort order on certain fields
This commit is contained in:
Danny Tylman 2016-08-11 11:35:08 +03:00
parent 7d4b7fb67d
commit b585c5786b
2 changed files with 13 additions and 13 deletions

View File

@ -29,9 +29,6 @@ import (
"github.com/blevesearch/bleve/index"
"github.com/blevesearch/bleve/index/store/null"
"github.com/blevesearch/bleve/search"
"github.com/Pallinder/go-randomdata"
"github.com/divan/num2words"
)
func TestCrud(t *testing.T) {
@ -731,18 +728,21 @@ func TestSortMatchSearch(t *testing.T) {
t.Fatal(err)
}
names := []string{"Noam", "Uri", "David", "Yosef", "Eitan", "Itay", "Ariel", "Daniel", "Omer", "Yogev", "Yehonatan", "Moshe", "Mohammed", "Yusuf", "Omar"}
days := []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
numbers := []string{"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve"}
for i := 0; i < 200; i++ {
doc := make(map[string]interface{})
doc["Name"] = randomdata.SillyName()
doc["Day"] = randomdata.Day()
doc["Number"] = num2words.Convert(i)
doc["Name"] = names[i%len(names)]
doc["Day"] = days[i%len(days)]
doc["Number"] = numbers[i%len(numbers)]
err = index.Index(fmt.Sprintf("%d", i), doc)
if err != nil {
t.Fatal(err)
}
}
req := NewSearchRequest(NewMatchQuery("one"))
req := NewSearchRequest(NewMatchQuery("One"))
req.SortBy("Day", true)
req.SortBy("Name", true)
req.Fields = []string{"*"}

View File

@ -167,9 +167,9 @@ func textFieldCompare(i, j *document.TextField, ascends bool) (bool, bool) {
return true, false
}
if ascends {
return false, ivalue < jvalue
return false, ivalue > jvalue
}
return false, ivalue > jvalue
return false, ivalue < jvalue
}
func numericFieldCompare(i, j *document.NumericField, ascends bool) (bool, bool) {
@ -179,9 +179,9 @@ func numericFieldCompare(i, j *document.NumericField, ascends bool) (bool, bool)
return true, false
}
if ascends {
return false, ivalue < jvalue
return false, ivalue > jvalue
}
return false, ivalue > jvalue
return false, ivalue < jvalue
}
func dateTimeFieldCompare(i, j *document.DateTimeField, ascends bool) (bool, bool) {
@ -191,9 +191,9 @@ func dateTimeFieldCompare(i, j *document.DateTimeField, ascends bool) (bool, boo
return true, false
}
if ascends {
return false, ivalue.Before(jvalue)
return false, ivalue.After(jvalue)
}
return false, ivalue.After(jvalue)
return false, ivalue.Before(jvalue)
}
func boolFieldCompare(i, j *document.BooleanField, ascends bool) (bool, bool) {