Skip to content

Commit

Permalink
Fix tests for suggester category query
Browse files Browse the repository at this point in the history
  • Loading branch information
olivere committed Jun 16, 2017
1 parent e3b7c0a commit 3113f9b
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions suggester_context_category_test.go
Expand Up @@ -90,9 +90,19 @@ func TestSuggesterCategoryQueryWithTwoValues(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expected := `{"color":[{"context":"red"},{"context":"yellow"}]}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
expectedOutcomes := []string{
`{"color":[{"context":"red"},{"context":"yellow"}]}`,
`{"color":[{"context":"yellow"},{"context":"red"}]}`,
}
var match bool
for _, expected := range expectedOutcomes {
if got == expected {
match = true
break
}
}
if !match {
t.Errorf("expected any of %v\n,got:\n%s", expectedOutcomes, got)
}
}

Expand All @@ -108,9 +118,19 @@ func TestSuggesterCategoryQueryWithBoost(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expected := `{"color":[{"context":"red"},{"boost":4,"context":"yellow"}]}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
expectedOutcomes := []string{
`{"color":[{"context":"red"},{"boost":4,"context":"yellow"}]}`,
`{"color":[{"boost":4,"context":"yellow"},{"context":"red"}]}`,
}
var match bool
for _, expected := range expectedOutcomes {
if got == expected {
match = true
break
}
}
if !match {
t.Errorf("expected any of %v\n,got:\n%v", expectedOutcomes, got)
}
}

Expand Down Expand Up @@ -138,6 +158,6 @@ func TestSuggesterCategoryQueryWithoutBoost(t *testing.T) {
}
}
if !match {
t.Errorf("expected any of %v", expectedOutcomes)
t.Errorf("expected any of %v\n,got:\n%s", expectedOutcomes, got)
}
}

0 comments on commit 3113f9b

Please sign in to comment.