YUKI Hiroshi
null+****@clear*****
Fri Jan 31 16:50:20 JST 2014
YUKI Hiroshi 2014-01-31 16:50:20 +0900 (Fri, 31 Jan 2014) New Revision: e4594de5472faad381c9a7f25d3e16e1c6aaff08 https://github.com/droonga/fluent-plugin-droonga/commit/e4594de5472faad381c9a7f25d3e16e1c6aaff08 Message: Migrate test for complex sortBy Modified files: test/unit/plugin/distributor/test_search_planner.rb Modified: test/unit/plugin/distributor/test_search_planner.rb (+79 -0) =================================================================== --- test/unit/plugin/distributor/test_search_planner.rb 2014-01-31 17:19:43 +0900 (442d2a2) +++ test/unit/plugin/distributor/test_search_planner.rb 2014-01-31 16:50:20 +0900 (71546e5) @@ -707,6 +707,85 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase gather_message["body"]["users_reduced"]) end end + + class ComplexSortByTest < self + def setup + @output = { + "elements" => ["records"], + "attributes" => ["_key"], + "limit" => 1, + } + @sort_by = { + "keys" => ["_key"], + } + @request = { + "type" => "search", + "dataset" => "Droonga", + "body" => { + "queries" => { + "users" => { + "source" => "User", + "sortBy" => @sort_by, + "output" => @output, + }, + }, + }, + } + end + + def test_dependencies + reduce_inputs = ["errors", "users"] + gather_inputs = ["errors_reduced", "users_reduced"] + assert_equal(expected_dependencies(reduce_inputs, gather_inputs), + dependencies) + end + + def test_broadcast_message + assert_valid_broadcast_message + changed_sort_by_parameters = { + "offset" => 0, + "limit" => 1, + } + assert_equal({ + "queries" => { + "users" => { + "source" => "User", + "sortBy" => @sort_by.merge(changed_sort_by_parameters), + "output" => @output, + }, + }, + }, + broadcast_message["body"]) + end + + def test_reduce_body + assert_equal({ + "users_reduced" => { + "records" => { + "type" => "sort", + "operators" => [ + { "column" => 0, "operator" => "<" }, + ], + "limit" => 1, + }, + }, + }, + reduce_message["body"]["users"]) + end + + def test_gather_records + assert_equal({ + "elements" => { + "records" => { + "attributes" => ["_key"], + "limit" => 1, + }, + }, + "output" => "users", + }, + gather_message["body"]["users_reduced"]) + end + end end -------------- next part -------------- HTML����������������������������...Download