Kouhei Sutou
null+****@clear*****
Tue Apr 9 18:56:22 JST 2013
Kouhei Sutou 2013-04-09 18:56:22 +0900 (Tue, 09 Apr 2013) New Revision: 4b91fa0ca3f17f1106b15a9b5185fcf94ad71bb8 https://github.com/groonga/fluent-plugin-droonga/commit/4b91fa0ca3f17f1106b15a9b5185fcf94ad71bb8 Message: Add tests for attributes parameter Modified files: test/plugin/test_handler_search.rb Modified: test/plugin/test_handler_search.rb (+76 -0) =================================================================== --- test/plugin/test_handler_search.rb 2013-04-09 18:47:09 +0900 (7047243) +++ test/plugin/test_handler_search.rb 2013-04-09 18:56:22 +0900 (8c13226) @@ -146,5 +146,81 @@ class SearchHandlerTest < Test::Unit::TestCase }, }) end + + class AttributesTest < self + class ArrayTest < self + def test_source_only + expected = { + "sections-result" => { + "records" => [ + { + "_key" => "1.1", + "title" => "Groonga overview", + }, + { + "_key" => "1.2", + "title" => "Full text search and Instant update", + }, + { + "_key" => "1.3", + "title" => "Column store and aggregate query", + }, + ], + }, + } + request = { + "queries" => { + "sections-result" => { + "source" => "Sections", + "output" => { + "limit" => 3, + "attributes" => ["_key", "title"], + }, + }, + }, + } + assert_search(expected, request) + end + + def test_label + expected = { + "sections-result" => { + "records" => [ + { + "key" => "1.1", + "title" => "Groonga overview", + }, + { + "key" => "1.2", + "title" => "Full text search and Instant update", + }, + { + "key" => "1.3", + "title" => "Column store and aggregate query", + }, + ], + }, + } + request = { + "queries" => { + "sections-result" => { + "source" => "Sections", + "output" => { + "limit" => 3, + "attributes" => [ + { + "label" => "key", + "source" => "_key", + }, + "title", + ], + }, + }, + }, + } + assert_search(expected, request) + end + end + end end end -------------- next part -------------- HTML����������������������������... Download