@@ -6,6 +6,12 @@ defmodule SkillControllerSearchIntegrationTest do
66 @ test_index "skills"
77 @ type_value "title"
88
9+ @ elixir % { "id" => 1 , "description" => "Elixir is an awesome functional language" , "title" => "Elixir" , "original_row" => 1 }
10+ @ ruby % { "id" => 2 , "description" => "Ruby is an awesome OO language" , "title" => "Ruby" , "original_row" => 2 }
11+ @ rails % { "id" => 3 , "description" => "Rails is a modern framework" , "title" => "Rails" , "original_row" => 3 }
12+ @ css % { "id" => 4 , "description" => "CSS is pretty cool too" , "title" => "CSS" , "original_row" => 4 }
13+ @ phoenix % { "id" => 5 , "description" => "Phoenix is a super framework" , "title" => "Phoenix" , "original_row" => 5 }
14+
915 setup do
1016 ElasticSearchHelper . delete ( @ test_url , @ test_index )
1117 ElasticSearchHelper . create_index ( @ test_url , @ test_index , @ type_value )
@@ -15,7 +21,7 @@ defmodule SkillControllerSearchIntegrationTest do
1521
1622 test "search partial word" do
1723 results = ElasticSearchHelper . search ( @ test_url , @ test_index , "title" , "ru" )
18- assert results == [ "Ruby" ]
24+ assert results == [ @ ruby ]
1925 end
2026
2127 test "fuzzy search partial word" do
@@ -25,12 +31,12 @@ defmodule SkillControllerSearchIntegrationTest do
2531
2632 test "search whole word" do
2733 results = ElasticSearchHelper . search ( @ test_url , @ test_index , "title" , "css" )
28- assert results == [ "CSS" ]
34+ assert results == [ @ css ]
2935 end
3036
3137 test "fuzzy search whole word" do
3238 results = ElasticSearchHelper . search ( @ test_url , @ test_index , "title" , "csw" )
33- assert results == [ "CSS" ]
39+ assert results == [ @ css ]
3440 end
3541
3642 test "search no matches" do
@@ -40,10 +46,11 @@ defmodule SkillControllerSearchIntegrationTest do
4046
4147 test "match all entries" do
4248 results = ElasticSearchHelper . match_all ( @ test_url , @ test_index , "title" )
43- assert results -- [ "Elixir" , "Ruby" , "Rails" , "CSS" ] == [ ]
49+ assert results -- [ @ elixir , @ ruby , @ rails , @ css ] == [ ]
4450 end
4551
4652 def init do
47- ElasticSearchHelper . add_documents ( @ test_url , @ test_index , @ type_value , [ "Elixir" , "Ruby" , "Rails" , "CSS" ] , [ refresh: true ] )
53+ ElasticSearchHelper . add_documents ( @ test_url , @ test_index , @ type_value ,
54+ [ @ elixir , @ css , @ ruby ] , [ refresh: true ] )
4855 end
4956end
0 commit comments