Skip to content

Commit

Permalink
🎨 Removing options for expected output, the json fields should be sor…
Browse files Browse the repository at this point in the history
…ted alphabetically.
  • Loading branch information
peteclark-ft committed Jun 16, 2017
1 parent 84c53d7 commit 619cd51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
7 changes: 3 additions & 4 deletions suggester_completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ func TestCompletionSuggesterSourceWithMultipleContexts(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expectedOption1 := `{"song-suggest":{"text":"n","completion":{"contexts":{"artist":[{"context":"Sting"}],"label":[{"context":"BMG"}]},"field":"suggest"}}}`
expectedOption2 := `{"song-suggest":{"text":"n","completion":{"contexts":{"label":[{"context":"BMG"}],"artist":[{"context":"Sting"}]},"field":"suggest"}}}`
if got != expectedOption1 && got != expectedOption2 {
t.Errorf("expected either\n%s\nor\n%s\n,got:\n%s", expectedOption1, expectedOption2, got)
expected := `{"song-suggest":{"text":"n","completion":{"contexts":{"artist":[{"context":"Sting"}],"label":[{"context":"BMG"}]},"field":"suggest"}}}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
}
}
21 changes: 9 additions & 12 deletions suggester_context_category_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ func TestSuggesterCategoryQueryWithTwoValues(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expectedOption1 := `{"color":[{"context":"red"},{"context":"yellow"}]}`
expectedOption2 := `{"color":[{"context":"yellow"},{"context":"red"}]}` // order is irrelevant to the results, and we model the query with a map which has no order guarantees
if got != expectedOption1 && got != expectedOption2 {
t.Errorf("expected either\n%s\nor\n%s\n,got:\n%s", expectedOption1, expectedOption2, got)
expected := `{"color":[{"context":"red"},{"context":"yellow"}]}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
}
}

Expand All @@ -109,10 +108,9 @@ func TestSuggesterCategoryQueryWithBoost(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expectedOption1 := `{"color":[{"context":"red"},{"boost":4,"context":"yellow"}]}`
expectedOption2 := `{"color":[{"boost":4,"context":"yellow"},{"context":"red"}]}`
if got != expectedOption1 && got != expectedOption2 {
t.Errorf("expected either\n%s\nor\n%s\n,got:\n%s", expectedOption1, expectedOption2, got)
expected := `{"color":[{"context":"red"},{"boost":4,"context":"yellow"}]}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
}
}

Expand All @@ -128,9 +126,8 @@ func TestSuggesterCategoryQueryWithoutBoost(t *testing.T) {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expectedOption1 := `{"color":[{"context":"red"},{"context":"yellow"}]}`
expectedOption2 := `{"color":[{"context":"yellow"},{"context":"red"}]}`
if got != expectedOption1 && got != expectedOption2 {
t.Errorf("expected either\n%s\nor\n%s\n,got:\n%s", expectedOption1, expectedOption2, got)
expected := `{"color":[{"context":"red"},{"context":"yellow"}]}`
if got != expected {
t.Errorf("expected %s\n,got:\n%s", expected, got)
}
}

0 comments on commit 619cd51

Please sign in to comment.