droonga-engine 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.dir-locals.el +3 -0
- data/.gitignore +6 -0
- data/.travis.yml +15 -0
- data/.yardopts +7 -0
- data/Gemfile +66 -0
- data/LICENSE.txt +14 -0
- data/README.md +17 -0
- data/Rakefile +64 -0
- data/benchmark/benchmark.rb +123 -0
- data/benchmark/utils.rb +246 -0
- data/benchmark/watch/benchmark-notify.rb +143 -0
- data/benchmark/watch/benchmark-notify.sh +20 -0
- data/benchmark/watch/benchmark-publish.rb +120 -0
- data/benchmark/watch/benchmark-scan.rb +213 -0
- data/bin/droonga-catalog-generate +103 -0
- data/bin/droonga-engine +20 -0
- data/bin/droonga-engine-service +20 -0
- data/doc/text/news.md +106 -0
- data/droonga-engine.gemspec +52 -0
- data/lib/droonga/adapter.rb +48 -0
- data/lib/droonga/adapter_runner.rb +104 -0
- data/lib/droonga/catalog/base.rb +41 -0
- data/lib/droonga/catalog/collection_volume.rb +106 -0
- data/lib/droonga/catalog/dataset.rb +69 -0
- data/lib/droonga/catalog/errors.rb +113 -0
- data/lib/droonga/catalog/schema.rb +186 -0
- data/lib/droonga/catalog/single_volume.rb +28 -0
- data/lib/droonga/catalog/slice.rb +41 -0
- data/lib/droonga/catalog/version1.rb +427 -0
- data/lib/droonga/catalog/version2.rb +96 -0
- data/lib/droonga/catalog/version2_validator.rb +63 -0
- data/lib/droonga/catalog/volume.rb +33 -0
- data/lib/droonga/catalog/volume_collection.rb +56 -0
- data/lib/droonga/catalog_generator.rb +156 -0
- data/lib/droonga/catalog_loader.rb +56 -0
- data/lib/droonga/catalog_observer.rb +83 -0
- data/lib/droonga/collector.rb +38 -0
- data/lib/droonga/collector_message.rb +71 -0
- data/lib/droonga/collector_runner.rb +64 -0
- data/lib/droonga/collectors/and.rb +26 -0
- data/lib/droonga/collectors/or.rb +26 -0
- data/lib/droonga/collectors/sum.rb +26 -0
- data/lib/droonga/collectors.rb +18 -0
- data/lib/droonga/dispatcher.rb +326 -0
- data/lib/droonga/distributed_command_planner.rb +179 -0
- data/lib/droonga/distributor.rb +87 -0
- data/lib/droonga/engine/command/droonga_engine.rb +441 -0
- data/lib/droonga/engine/version.rb +20 -0
- data/lib/droonga/engine.rb +80 -0
- data/lib/droonga/engine_state.rb +79 -0
- data/lib/droonga/error.rb +73 -0
- data/lib/droonga/error_messages.rb +33 -0
- data/lib/droonga/event_loop.rb +46 -0
- data/lib/droonga/farm.rb +58 -0
- data/lib/droonga/fluent_message_receiver.rb +191 -0
- data/lib/droonga/fluent_message_sender.rb +140 -0
- data/lib/droonga/forwarder.rb +119 -0
- data/lib/droonga/handler.rb +49 -0
- data/lib/droonga/handler_message.rb +61 -0
- data/lib/droonga/handler_messenger.rb +119 -0
- data/lib/droonga/handler_runner.rb +125 -0
- data/lib/droonga/input_message.rb +51 -0
- data/lib/droonga/job_protocol.rb +20 -0
- data/lib/droonga/job_pusher.rb +179 -0
- data/lib/droonga/job_receiver.rb +70 -0
- data/lib/droonga/loggable.rb +29 -0
- data/lib/droonga/logger.rb +142 -0
- data/lib/droonga/message_matcher.rb +109 -0
- data/lib/droonga/output_message.rb +55 -0
- data/lib/droonga/planner.rb +47 -0
- data/lib/droonga/pluggable.rb +31 -0
- data/lib/droonga/plugin/metadata/adapter_input_message.rb +39 -0
- data/lib/droonga/plugin/metadata/adapter_output_message.rb +39 -0
- data/lib/droonga/plugin/metadata/collector_message.rb +39 -0
- data/lib/droonga/plugin/metadata/handler_action.rb +39 -0
- data/lib/droonga/plugin/metadata/input_message.rb +54 -0
- data/lib/droonga/plugin.rb +43 -0
- data/lib/droonga/plugin_loader.rb +63 -0
- data/lib/droonga/plugin_registry.rb +66 -0
- data/lib/droonga/plugins/basic.rb +54 -0
- data/lib/droonga/plugins/crud.rb +145 -0
- data/lib/droonga/plugins/dump.rb +97 -0
- data/lib/droonga/plugins/error.rb +51 -0
- data/lib/droonga/plugins/groonga/column_create.rb +123 -0
- data/lib/droonga/plugins/groonga/column_list.rb +124 -0
- data/lib/droonga/plugins/groonga/column_remove.rb +65 -0
- data/lib/droonga/plugins/groonga/column_rename.rb +67 -0
- data/lib/droonga/plugins/groonga/delete.rb +117 -0
- data/lib/droonga/plugins/groonga/generic_command.rb +105 -0
- data/lib/droonga/plugins/groonga/generic_response.rb +43 -0
- data/lib/droonga/plugins/groonga/select.rb +236 -0
- data/lib/droonga/plugins/groonga/table_create.rb +111 -0
- data/lib/droonga/plugins/groonga/table_list.rb +120 -0
- data/lib/droonga/plugins/groonga/table_remove.rb +57 -0
- data/lib/droonga/plugins/groonga.rb +37 -0
- data/lib/droonga/plugins/search/distributed_search_planner.rb +407 -0
- data/lib/droonga/plugins/search.rb +146 -0
- data/lib/droonga/plugins/watch.rb +178 -0
- data/lib/droonga/processor.rb +63 -0
- data/lib/droonga/reducer.rb +169 -0
- data/lib/droonga/replier.rb +49 -0
- data/lib/droonga/schema_applier.rb +167 -0
- data/lib/droonga/searcher/mecab_filter.rb +67 -0
- data/lib/droonga/searcher.rb +733 -0
- data/lib/droonga/server.rb +45 -0
- data/lib/droonga/session.rb +99 -0
- data/lib/droonga/single_step.rb +68 -0
- data/lib/droonga/single_step_definition.rb +54 -0
- data/lib/droonga/slice.rb +122 -0
- data/lib/droonga/status_code.rb +25 -0
- data/lib/droonga/step_runner.rb +64 -0
- data/lib/droonga/sweeper.rb +42 -0
- data/lib/droonga/test/stub_handler.rb +37 -0
- data/lib/droonga/test/stub_handler_message.rb +35 -0
- data/lib/droonga/test/stub_handler_messenger.rb +34 -0
- data/lib/droonga/test/stub_planner.rb +31 -0
- data/lib/droonga/test.rb +21 -0
- data/lib/droonga/watch_schema.rb +92 -0
- data/lib/droonga/watcher.rb +257 -0
- data/lib/droonga/worker.rb +61 -0
- data/sample/cluster/catalog.json +42 -0
- data/sample/mecab_filter/data.grn +7 -0
- data/sample/mecab_filter/ddl.grn +7 -0
- data/sample/mecab_filter/search_with_mecab_filter.json +21 -0
- data/sample/mecab_filter/search_without_mecab_filter.json +21 -0
- data/test/command/config/default/catalog.json +85 -0
- data/test/command/config/default/fluentd.conf +11 -0
- data/test/command/config/version1/catalog.json +68 -0
- data/test/command/config/version1/fluentd.conf +11 -0
- data/test/command/fixture/documents.jsons +208 -0
- data/test/command/fixture/event.jsons +41 -0
- data/test/command/fixture/user-table-array.jsons +38 -0
- data/test/command/fixture/user-table.jsons +47 -0
- data/test/command/run-test.rb +34 -0
- data/test/command/suite/add/dimension/column.catalog.json +28 -0
- data/test/command/suite/add/dimension/column.expected +41 -0
- data/test/command/suite/add/dimension/column.test +51 -0
- data/test/command/suite/add/dimension/integer.catalog.json +19 -0
- data/test/command/suite/add/dimension/integer.expected +41 -0
- data/test/command/suite/add/dimension/integer.test +51 -0
- data/test/command/suite/add/error/invalid-integer.expected +46 -0
- data/test/command/suite/add/error/invalid-integer.test +12 -0
- data/test/command/suite/add/error/invalid-time.expected +46 -0
- data/test/command/suite/add/error/invalid-time.test +12 -0
- data/test/command/suite/add/error/missing-key.expected +25 -0
- data/test/command/suite/add/error/missing-key.test +16 -0
- data/test/command/suite/add/error/missing-table.expected +25 -0
- data/test/command/suite/add/error/missing-table.test +16 -0
- data/test/command/suite/add/error/unknown-column.expected +46 -0
- data/test/command/suite/add/error/unknown-column.test +12 -0
- data/test/command/suite/add/error/unknown-table.expected +25 -0
- data/test/command/suite/add/error/unknown-table.test +17 -0
- data/test/command/suite/add/minimum.expected +6 -0
- data/test/command/suite/add/minimum.test +11 -0
- data/test/command/suite/add/with-values.expected +6 -0
- data/test/command/suite/add/with-values.test +17 -0
- data/test/command/suite/add/without-key.expected +6 -0
- data/test/command/suite/add/without-key.test +16 -0
- data/test/command/suite/groonga/column_create/scalar.expected +26 -0
- data/test/command/suite/groonga/column_create/scalar.test +17 -0
- data/test/command/suite/groonga/column_create/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_create/vector.expected +26 -0
- data/test/command/suite/groonga/column_create/vector.test +18 -0
- data/test/command/suite/groonga/column_list/success.expected +86 -0
- data/test/command/suite/groonga/column_list/success.test +24 -0
- data/test/command/suite/groonga/column_list/unknown-table.expected +13 -0
- data/test/command/suite/groonga/column_list/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_remove/success.expected +39 -0
- data/test/command/suite/groonga/column_remove/success.test +25 -0
- data/test/command/suite/groonga/column_remove/unknown-column.expected +27 -0
- data/test/command/suite/groonga/column_remove/unknown-column.test +16 -0
- data/test/command/suite/groonga/column_remove/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_remove/unknown-table.test +7 -0
- data/test/command/suite/groonga/column_rename/success.expected +39 -0
- data/test/command/suite/groonga/column_rename/success.test +26 -0
- data/test/command/suite/groonga/column_rename/unknown-column.expected +27 -0
- data/test/command/suite/groonga/column_rename/unknown-column.test +16 -0
- data/test/command/suite/groonga/column_rename/unknown-table.expected +14 -0
- data/test/command/suite/groonga/column_rename/unknown-table.test +7 -0
- data/test/command/suite/groonga/delete/duplicated-identifiers.expected +27 -0
- data/test/command/suite/groonga/delete/duplicated-identifiers.test +17 -0
- data/test/command/suite/groonga/delete/filter.expected +19 -0
- data/test/command/suite/groonga/delete/filter.test +19 -0
- data/test/command/suite/groonga/delete/invalid-filter.expected +14 -0
- data/test/command/suite/groonga/delete/invalid-filter.test +9 -0
- data/test/command/suite/groonga/delete/no-identifier.expected +27 -0
- data/test/command/suite/groonga/delete/no-identifier.test +15 -0
- data/test/command/suite/groonga/delete/success.expected +19 -0
- data/test/command/suite/groonga/delete/success.test +19 -0
- data/test/command/suite/groonga/delete/unknown-table.expected +14 -0
- data/test/command/suite/groonga/delete/unknown-table.test +7 -0
- data/test/command/suite/groonga/select/minimum.expected +22 -0
- data/test/command/suite/groonga/select/minimum.test +8 -0
- data/test/command/suite/groonga/table_create/array.expected +14 -0
- data/test/command/suite/groonga/table_create/array.test +8 -0
- data/test/command/suite/groonga/table_create/hash.expected +13 -0
- data/test/command/suite/groonga/table_create/hash.test +8 -0
- data/test/command/suite/groonga/table_list/success.expected +71 -0
- data/test/command/suite/groonga/table_list/success.test +15 -0
- data/test/command/suite/groonga/table_remove/success.expected +13 -0
- data/test/command/suite/groonga/table_remove/success.test +8 -0
- data/test/command/suite/groonga/table_remove/unknown-table.expected +14 -0
- data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
- data/test/command/suite/message/error/missing-dataset.expected +9 -0
- data/test/command/suite/message/error/missing-dataset.test +5 -0
- data/test/command/suite/message/error/unknown-dataset.expected +9 -0
- data/test/command/suite/message/error/unknown-dataset.test +6 -0
- data/test/command/suite/message/error/unknown-type.expected +9 -0
- data/test/command/suite/message/error/unknown-type.test +6 -0
- data/test/command/suite/search/adjusters/multiple.catalog.json +38 -0
- data/test/command/suite/search/adjusters/multiple.expected +19 -0
- data/test/command/suite/search/adjusters/multiple.test +75 -0
- data/test/command/suite/search/adjusters/one.catalog.json +38 -0
- data/test/command/suite/search/adjusters/one.expected +19 -0
- data/test/command/suite/search/adjusters/one.test +66 -0
- data/test/command/suite/search/attributes/array.expected +21 -0
- data/test/command/suite/search/attributes/array.test +28 -0
- data/test/command/suite/search/attributes/hash.expected +30 -0
- data/test/command/suite/search/attributes/hash.test +36 -0
- data/test/command/suite/search/complex.expected +48 -0
- data/test/command/suite/search/complex.test +23 -0
- data/test/command/suite/search/condition/nested.expected +15 -0
- data/test/command/suite/search/condition/nested.test +27 -0
- data/test/command/suite/search/condition/query/nonexistent_column.catalog.json +37 -0
- data/test/command/suite/search/condition/query/nonexistent_column.expected +48 -0
- data/test/command/suite/search/condition/query/nonexistent_column.test +33 -0
- data/test/command/suite/search/condition/query/syntax_error.catalog.json +36 -0
- data/test/command/suite/search/condition/query/syntax_error.expected +48 -0
- data/test/command/suite/search/condition/query/syntax_error.test +33 -0
- data/test/command/suite/search/condition/query.expected +24 -0
- data/test/command/suite/search/condition/query.test +23 -0
- data/test/command/suite/search/condition/script.expected +24 -0
- data/test/command/suite/search/condition/script.test +26 -0
- data/test/command/suite/search/error/cyclic-source.expected +14 -0
- data/test/command/suite/search/error/cyclic-source.test +12 -0
- data/test/command/suite/search/error/deeply-cyclic-source.expected +17 -0
- data/test/command/suite/search/error/deeply-cyclic-source.test +15 -0
- data/test/command/suite/search/error/missing-source-parameter.expected +13 -0
- data/test/command/suite/search/error/missing-source-parameter.test +11 -0
- data/test/command/suite/search/error/no-query.expected +9 -0
- data/test/command/suite/search/error/no-query.test +7 -0
- data/test/command/suite/search/error/unknown-source.expected +52 -0
- data/test/command/suite/search/error/unknown-source.test +12 -0
- data/test/command/suite/search/group/count.expected +10 -0
- data/test/command/suite/search/group/count.test +18 -0
- data/test/command/suite/search/group/limit.expected +15 -0
- data/test/command/suite/search/group/limit.test +20 -0
- data/test/command/suite/search/group/string.expected +32 -0
- data/test/command/suite/search/group/string.test +40 -0
- data/test/command/suite/search/group/subrecord/with-sort.catalog.json +33 -0
- data/test/command/suite/search/group/subrecord/with-sort.expected +30 -0
- data/test/command/suite/search/group/subrecord/with-sort.test +81 -0
- data/test/command/suite/search/multiple/chained.expected +41 -0
- data/test/command/suite/search/multiple/chained.test +39 -0
- data/test/command/suite/search/multiple/parallel.expected +35 -0
- data/test/command/suite/search/multiple/parallel.test +35 -0
- data/test/command/suite/search/output/attributes/invalid.catalog.json +13 -0
- data/test/command/suite/search/output/attributes/invalid.expected +44 -0
- data/test/command/suite/search/output/attributes/invalid.test +28 -0
- data/test/command/suite/search/range/only-output.expected +24 -0
- data/test/command/suite/search/range/only-output.test +23 -0
- data/test/command/suite/search/range/only-sort.expected +24 -0
- data/test/command/suite/search/range/only-sort.test +26 -0
- data/test/command/suite/search/range/sort-and-output.expected +21 -0
- data/test/command/suite/search/range/sort-and-output.test +27 -0
- data/test/command/suite/search/range/too-large-output-offset.expected +12 -0
- data/test/command/suite/search/range/too-large-output-offset.test +23 -0
- data/test/command/suite/search/range/too-large-sort-offset.expected +12 -0
- data/test/command/suite/search/range/too-large-sort-offset.test +26 -0
- data/test/command/suite/search/response/elapsed_time.catalog.json +13 -0
- data/test/command/suite/search/response/elapsed_time.expected +11 -0
- data/test/command/suite/search/response/elapsed_time.test +26 -0
- data/test/command/suite/search/response/records/value/time.expected +20 -0
- data/test/command/suite/search/response/records/value/time.test +22 -0
- data/test/command/suite/search/simple.expected +48 -0
- data/test/command/suite/search/simple.test +22 -0
- data/test/command/suite/search/sort/default-offset-limit.expected +39 -0
- data/test/command/suite/search/sort/default-offset-limit.test +24 -0
- data/test/command/suite/search/sort/invisible-column.expected +24 -0
- data/test/command/suite/search/sort/invisible-column.test +26 -0
- data/test/command/suite/watch/subscribe.expected +6 -0
- data/test/command/suite/watch/subscribe.test +9 -0
- data/test/command/suite/watch/unsubscribe.expected +6 -0
- data/test/command/suite/watch/unsubscribe.test +9 -0
- data/test/performance/run-test.rb +56 -0
- data/test/performance/watch/catalog.json +33 -0
- data/test/performance/watch/feed.json +9 -0
- data/test/performance/watch/fluentd.conf +11 -0
- data/test/performance/watch/subscribe.json +3 -0
- data/test/unit/catalog/test_collection_volume.rb +103 -0
- data/test/unit/catalog/test_dataset.rb +104 -0
- data/test/unit/catalog/test_schema.rb +226 -0
- data/test/unit/catalog/test_single_volume.rb +31 -0
- data/test/unit/catalog/test_slice.rb +92 -0
- data/test/unit/catalog/test_version1.rb +361 -0
- data/test/unit/catalog/test_version2.rb +124 -0
- data/test/unit/catalog/test_version2_validator.rb +66 -0
- data/test/unit/catalog/test_volume_collection.rb +50 -0
- data/test/unit/fixtures/array.grn +18 -0
- data/test/unit/fixtures/catalog/version1.json +40 -0
- data/test/unit/fixtures/catalog/version2.json +62 -0
- data/test/unit/fixtures/document.grn +34 -0
- data/test/unit/fixtures/reference/array.grn +11 -0
- data/test/unit/fixtures/reference/hash.grn +7 -0
- data/test/unit/helper/distributed_search_planner_helper.rb +83 -0
- data/test/unit/helper/fixture.rb +28 -0
- data/test/unit/helper/plugin_helper.rb +38 -0
- data/test/unit/helper/sandbox.rb +86 -0
- data/test/unit/helper/stub_worker.rb +27 -0
- data/test/unit/helper/watch_helper.rb +23 -0
- data/test/unit/helper.rb +28 -0
- data/test/unit/plugins/crud/test_add.rb +190 -0
- data/test/unit/plugins/groonga/select/test_adapter_input.rb +510 -0
- data/test/unit/plugins/groonga/select/test_adapter_output.rb +201 -0
- data/test/unit/plugins/groonga/test_column_create.rb +171 -0
- data/test/unit/plugins/groonga/test_column_list.rb +170 -0
- data/test/unit/plugins/groonga/test_column_remove.rb +98 -0
- data/test/unit/plugins/groonga/test_column_rename.rb +105 -0
- data/test/unit/plugins/groonga/test_delete.rb +127 -0
- data/test/unit/plugins/groonga/test_table_create.rb +147 -0
- data/test/unit/plugins/groonga/test_table_list.rb +184 -0
- data/test/unit/plugins/groonga/test_table_remove.rb +61 -0
- data/test/unit/plugins/search/planner/test_basic.rb +120 -0
- data/test/unit/plugins/search/planner/test_group_by.rb +573 -0
- data/test/unit/plugins/search/planner/test_output.rb +388 -0
- data/test/unit/plugins/search/planner/test_sort_by.rb +938 -0
- data/test/unit/plugins/search/test_collector.rb +806 -0
- data/test/unit/plugins/search/test_handler.rb +930 -0
- data/test/unit/plugins/search/test_planner.rb +174 -0
- data/test/unit/plugins/test_basic.rb +510 -0
- data/test/unit/plugins/test_groonga.rb +70 -0
- data/test/unit/plugins/test_watch.rb +211 -0
- data/test/unit/run-test.rb +56 -0
- data/test/unit/test_catalog_generator.rb +93 -0
- data/test/unit/test_message_matcher.rb +160 -0
- data/test/unit/test_schema_applier.rb +59 -0
- data/test/unit/test_sweeper.rb +95 -0
- data/test/unit/test_watch_schema.rb +57 -0
- data/test/unit/test_watcher.rb +336 -0
- metadata +759 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
class ColumnRenameTest < GroongaHandlerTest
|
|
17
|
+
def create_handler
|
|
18
|
+
Droonga::Plugins::Groonga::ColumnRename::Handler.new("droonga",
|
|
19
|
+
@handler.context,
|
|
20
|
+
@messenger,
|
|
21
|
+
@loop)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_success
|
|
25
|
+
Groonga::Schema.define do |schema|
|
|
26
|
+
schema.create_table("Books", :type => :hash)
|
|
27
|
+
schema.change_table("Books") do |table|
|
|
28
|
+
table.column("title", "ShortText", :type => :scalar)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
message = {
|
|
32
|
+
"table" => "Books",
|
|
33
|
+
"name" => "title",
|
|
34
|
+
"new_name" => "label",
|
|
35
|
+
}
|
|
36
|
+
response = process(:column_rename, message)
|
|
37
|
+
assert_equal(
|
|
38
|
+
[NORMALIZED_HEADER_SUCCESS, true],
|
|
39
|
+
[normalize_header(response.first), response.last]
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_unknown_table
|
|
44
|
+
message = {
|
|
45
|
+
"table" => "Unknown",
|
|
46
|
+
"name" => "title",
|
|
47
|
+
"new_name" => "label",
|
|
48
|
+
"type" => "ShortText",
|
|
49
|
+
}
|
|
50
|
+
response = process(:column_rename, message)
|
|
51
|
+
assert_equal(
|
|
52
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
53
|
+
[normalize_header(response.first), response.last]
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_unknown_column
|
|
58
|
+
Groonga::Schema.define do |schema|
|
|
59
|
+
schema.create_table("Books", :type => :hash)
|
|
60
|
+
end
|
|
61
|
+
message = {
|
|
62
|
+
"table" => "Books",
|
|
63
|
+
"name" => "title",
|
|
64
|
+
"new_name" => "label",
|
|
65
|
+
}
|
|
66
|
+
response = process(:column_rename, message)
|
|
67
|
+
assert_equal(
|
|
68
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
69
|
+
[normalize_header(response.first), response.last]
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_rename
|
|
74
|
+
Groonga::Schema.define do |schema|
|
|
75
|
+
schema.create_table("Books", :type => :hash)
|
|
76
|
+
schema.change_table("Books") do |table|
|
|
77
|
+
table.column("title", "ShortText", :type => :scalar)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
process(:column_rename,
|
|
81
|
+
{"table" => "Books", "name" => "title", "new_name" => "label"})
|
|
82
|
+
assert_equal(<<-SCHEMA, dump)
|
|
83
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
84
|
+
column_create Books label COLUMN_SCALAR ShortText
|
|
85
|
+
SCHEMA
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_rename_with_index
|
|
89
|
+
Groonga::Schema.define do |schema|
|
|
90
|
+
schema.create_table("Books", :type => :hash)
|
|
91
|
+
schema.change_table("Books") do |table|
|
|
92
|
+
table.column("title", "ShortText", :type => :scalar)
|
|
93
|
+
table.index("Books", "title", :name => "entry_title")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
process(:column_rename,
|
|
97
|
+
{"table" => "Books", "name" => "title", "new_name" => "label"})
|
|
98
|
+
assert_equal(<<-SCHEMA, dump)
|
|
99
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
100
|
+
column_create Books label COLUMN_SCALAR ShortText
|
|
101
|
+
|
|
102
|
+
column_create Books entry_title COLUMN_INDEX Books label
|
|
103
|
+
SCHEMA
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
class DeleteTest < GroongaHandlerTest
|
|
17
|
+
def create_handler
|
|
18
|
+
Droonga::Plugins::Groonga::Delete::Handler.new("droonga",
|
|
19
|
+
@handler.context,
|
|
20
|
+
@messenger,
|
|
21
|
+
@loop)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_success
|
|
25
|
+
Groonga::Schema.define do |schema|
|
|
26
|
+
schema.create_table("Books", :type => :hash)
|
|
27
|
+
end
|
|
28
|
+
Groonga::Context.default["Books"].add("sample")
|
|
29
|
+
message = {
|
|
30
|
+
"table" => "Books",
|
|
31
|
+
"key" => "sample",
|
|
32
|
+
}
|
|
33
|
+
response = process(:delete, message)
|
|
34
|
+
assert_equal(
|
|
35
|
+
[NORMALIZED_HEADER_SUCCESS, true],
|
|
36
|
+
[normalize_header(response.first), response.last]
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_unknown_table
|
|
41
|
+
message = {
|
|
42
|
+
"table" => "Unknown",
|
|
43
|
+
}
|
|
44
|
+
response = process(:delete, message)
|
|
45
|
+
assert_equal(
|
|
46
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
47
|
+
[normalize_header(response.first), response.last]
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_no_identifier
|
|
52
|
+
Groonga::Schema.define do |schema|
|
|
53
|
+
schema.create_table("Books", :type => :hash)
|
|
54
|
+
end
|
|
55
|
+
message = {
|
|
56
|
+
"table" => "Books",
|
|
57
|
+
}
|
|
58
|
+
response = process(:delete, message)
|
|
59
|
+
assert_equal(
|
|
60
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
61
|
+
[normalize_header(response.first), response.last]
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
data(:key_and_id => { "key" => "key", "id" => "1" },
|
|
66
|
+
:id_and_filter => { "id" => "1", "filter" => "filter" },
|
|
67
|
+
:key_and_filter => { "key" => "key", "filter" => "filter" })
|
|
68
|
+
def test_duplicated_identifier(data)
|
|
69
|
+
Groonga::Schema.define do |schema|
|
|
70
|
+
schema.create_table("Books", :type => :hash)
|
|
71
|
+
end
|
|
72
|
+
message = {
|
|
73
|
+
"table" => "Books",
|
|
74
|
+
}.merge(data)
|
|
75
|
+
response = process(:delete, message)
|
|
76
|
+
assert_equal(
|
|
77
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
78
|
+
[normalize_header(response.first), response.last]
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
class DeleteTest < self
|
|
83
|
+
def test_key
|
|
84
|
+
Groonga::Schema.define do |schema|
|
|
85
|
+
schema.create_table("Books", :type => :hash)
|
|
86
|
+
end
|
|
87
|
+
Groonga::Context.default["Books"].add("sample")
|
|
88
|
+
process(:delete,
|
|
89
|
+
{"table" => "Books", "key" => "sample"})
|
|
90
|
+
assert_equal(<<-DUMP, dump)
|
|
91
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
92
|
+
DUMP
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_id
|
|
96
|
+
Groonga::Schema.define do |schema|
|
|
97
|
+
schema.create_table("Ages", :type => :array)
|
|
98
|
+
end
|
|
99
|
+
Groonga::Context.default["Ages"].add([])
|
|
100
|
+
process(:delete,
|
|
101
|
+
{"table" => "Ages", "id" => 1})
|
|
102
|
+
assert_equal(<<-DUMP, dump)
|
|
103
|
+
table_create Ages TABLE_NO_KEY
|
|
104
|
+
DUMP
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def test_filter
|
|
108
|
+
Groonga::Schema.define do |schema|
|
|
109
|
+
schema.create_table("Books", :type => :hash)
|
|
110
|
+
end
|
|
111
|
+
table = Groonga::Context.default["Books"]
|
|
112
|
+
table.add("Groonga")
|
|
113
|
+
table.add("Droonga")
|
|
114
|
+
process(:delete,
|
|
115
|
+
{"table" => "Books", "filter" => '_key @^ "D"'})
|
|
116
|
+
assert_equal(<<-DUMP, dump)
|
|
117
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
118
|
+
|
|
119
|
+
load --table Books
|
|
120
|
+
[
|
|
121
|
+
["_key"],
|
|
122
|
+
["Groonga"]
|
|
123
|
+
]
|
|
124
|
+
DUMP
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Copyright (C) 2013 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
class TableCreateTest < GroongaHandlerTest
|
|
17
|
+
def create_handler
|
|
18
|
+
Droonga::Plugins::Groonga::TableCreate::Handler.new("droonga",
|
|
19
|
+
@handler.context,
|
|
20
|
+
@messenger,
|
|
21
|
+
@loop)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_success
|
|
25
|
+
response = process(:table_create, {"name" => "Books"})
|
|
26
|
+
assert_equal(
|
|
27
|
+
[NORMALIZED_HEADER_SUCCESS, true],
|
|
28
|
+
[normalize_header(response.first), response.last]
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_failure
|
|
33
|
+
response = process(:table_create, {})
|
|
34
|
+
assert_equal(
|
|
35
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
36
|
+
[normalize_header(response.first), response.last]
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_name
|
|
41
|
+
process(:table_create, {"name" => "Books"})
|
|
42
|
+
assert_equal(<<-SCHEMA, dump)
|
|
43
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
44
|
+
SCHEMA
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class FlagsTest < self
|
|
48
|
+
data({
|
|
49
|
+
"TABLE_NO_KEY" => {
|
|
50
|
+
:flags => "TABLE_NO_KEY",
|
|
51
|
+
:schema => <<-SCHEMA,
|
|
52
|
+
table_create Books TABLE_NO_KEY
|
|
53
|
+
SCHEMA
|
|
54
|
+
},
|
|
55
|
+
"TABLE_HASH_KEY" => {
|
|
56
|
+
:flags => "TABLE_HASH_KEY",
|
|
57
|
+
:schema => <<-SCHEMA,
|
|
58
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
59
|
+
SCHEMA
|
|
60
|
+
},
|
|
61
|
+
"TABLE_PAT_KEY" => {
|
|
62
|
+
:flags => "TABLE_PAT_KEY",
|
|
63
|
+
:schema => <<-SCHEMA,
|
|
64
|
+
table_create Books TABLE_PAT_KEY --key_type ShortText
|
|
65
|
+
SCHEMA
|
|
66
|
+
},
|
|
67
|
+
"TABLE_DAT_KEY" => {
|
|
68
|
+
:flags => "TABLE_DAT_KEY",
|
|
69
|
+
:schema => <<-SCHEMA,
|
|
70
|
+
table_create Books TABLE_DAT_KEY --key_type ShortText
|
|
71
|
+
SCHEMA
|
|
72
|
+
},
|
|
73
|
+
"KEY_WITH_SIS with TABLE_PAT_KEY" => {
|
|
74
|
+
:flags => "KEY_WITH_SIS|TABLE_PAT_KEY",
|
|
75
|
+
:schema => <<-SCHEMA,
|
|
76
|
+
table_create Books TABLE_PAT_KEY|KEY_WITH_SIS --key_type ShortText
|
|
77
|
+
SCHEMA
|
|
78
|
+
},
|
|
79
|
+
"KEY_WITH_SIS without TABLE_PAT_KEY" => {
|
|
80
|
+
:flags => "TABLE_NO_KEY|KEY_WITH_SIS",
|
|
81
|
+
:schema => <<-SCHEMA,
|
|
82
|
+
table_create Books TABLE_NO_KEY
|
|
83
|
+
SCHEMA
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
def test_flags(data)
|
|
87
|
+
request = {
|
|
88
|
+
"name" => "Books",
|
|
89
|
+
"flags" => data[:flags],
|
|
90
|
+
}
|
|
91
|
+
process(:table_create, request)
|
|
92
|
+
assert_equal(data[:schema], dump)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class KeyTypeTest < self
|
|
97
|
+
def test_key_type
|
|
98
|
+
request = {
|
|
99
|
+
"name" => "Books",
|
|
100
|
+
"key_type" => "Int32",
|
|
101
|
+
}
|
|
102
|
+
process(:table_create, request)
|
|
103
|
+
assert_equal(<<-SCHEMA, dump)
|
|
104
|
+
table_create Books TABLE_HASH_KEY --key_type Int32
|
|
105
|
+
SCHEMA
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class ValueTypeTest < self
|
|
110
|
+
def test_value_type
|
|
111
|
+
request = {
|
|
112
|
+
"name" => "Books",
|
|
113
|
+
"value_type" => "Int32",
|
|
114
|
+
}
|
|
115
|
+
process(:table_create, request)
|
|
116
|
+
assert_equal(<<-SCHEMA, dump)
|
|
117
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText --value_type Int32
|
|
118
|
+
SCHEMA
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
class DefaultTokenizerTest < self
|
|
123
|
+
def test_default_tokenizer
|
|
124
|
+
request = {
|
|
125
|
+
"name" => "Books",
|
|
126
|
+
"default_tokenizer" => "TokenBigram",
|
|
127
|
+
}
|
|
128
|
+
process(:table_create, request)
|
|
129
|
+
assert_equal(<<-SCHEMA, dump)
|
|
130
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText --default_tokenizer TokenBigram
|
|
131
|
+
SCHEMA
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
class NormalizerTest < self
|
|
136
|
+
def test_normalizer
|
|
137
|
+
request = {
|
|
138
|
+
"name" => "Books",
|
|
139
|
+
"normalizer" => "NormalizerAuto",
|
|
140
|
+
}
|
|
141
|
+
process(:table_create, request)
|
|
142
|
+
assert_equal(<<-SCHEMA, dump)
|
|
143
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText --normalizer NormalizerAuto
|
|
144
|
+
SCHEMA
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
class TableListTest < GroongaHandlerTest
|
|
17
|
+
TABLES_HEADER = [
|
|
18
|
+
["id", "UInt32"],
|
|
19
|
+
["name", "ShortText"],
|
|
20
|
+
["path", "ShortText"],
|
|
21
|
+
["flags", "ShortText"],
|
|
22
|
+
["domain", "ShortText"],
|
|
23
|
+
["range", "ShortText"],
|
|
24
|
+
["default_tokenizer", "ShortText"],
|
|
25
|
+
["normalizer", "ShortText"],
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
def create_handler
|
|
29
|
+
Droonga::Plugins::Groonga::TableList::Handler.new("droonga",
|
|
30
|
+
@handler.context,
|
|
31
|
+
@messenger,
|
|
32
|
+
@loop)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_success
|
|
36
|
+
Groonga::Schema.define do |schema|
|
|
37
|
+
schema.create_table("Books", :type => :hash)
|
|
38
|
+
end
|
|
39
|
+
response = process(:column_list, {})
|
|
40
|
+
assert_equal(
|
|
41
|
+
NORMALIZED_HEADER_SUCCESS,
|
|
42
|
+
normalize_header(response.first)
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class ListTest < self
|
|
47
|
+
def test_hash_table
|
|
48
|
+
Groonga::Schema.define do |schema|
|
|
49
|
+
schema.create_table("Books", :type => :hash)
|
|
50
|
+
end
|
|
51
|
+
response = process(:table_list, {})
|
|
52
|
+
expected = [
|
|
53
|
+
TABLES_HEADER,
|
|
54
|
+
[256,
|
|
55
|
+
"Books",
|
|
56
|
+
@database_path.to_s + ".0000100",
|
|
57
|
+
"TABLE_HASH_KEY|PERSISTENT",
|
|
58
|
+
"ShortText",
|
|
59
|
+
nil,
|
|
60
|
+
nil,
|
|
61
|
+
nil],
|
|
62
|
+
]
|
|
63
|
+
assert_equal(expected, response.last)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_array_table
|
|
67
|
+
Groonga::Schema.define do |schema|
|
|
68
|
+
schema.create_table("HistoryEntries", :type => :array)
|
|
69
|
+
end
|
|
70
|
+
response = process(:table_list, {})
|
|
71
|
+
expected = [
|
|
72
|
+
TABLES_HEADER,
|
|
73
|
+
[256,
|
|
74
|
+
"HistoryEntries",
|
|
75
|
+
@database_path.to_s + ".0000100",
|
|
76
|
+
"TABLE_NO_KEY|PERSISTENT",
|
|
77
|
+
nil,
|
|
78
|
+
nil,
|
|
79
|
+
nil,
|
|
80
|
+
nil],
|
|
81
|
+
]
|
|
82
|
+
assert_equal(expected, response.last)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_patricia_trie_table
|
|
86
|
+
Groonga::Schema.define do |schema|
|
|
87
|
+
schema.create_table("Books", :type => :patricia_trie)
|
|
88
|
+
end
|
|
89
|
+
response = process(:table_list, {})
|
|
90
|
+
expected = [
|
|
91
|
+
TABLES_HEADER,
|
|
92
|
+
[256,
|
|
93
|
+
"Books",
|
|
94
|
+
@database_path.to_s + ".0000100",
|
|
95
|
+
"TABLE_PAT_KEY|PERSISTENT",
|
|
96
|
+
"ShortText",
|
|
97
|
+
nil,
|
|
98
|
+
nil,
|
|
99
|
+
nil],
|
|
100
|
+
]
|
|
101
|
+
assert_equal(expected, response.last)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_double_array_trie_table
|
|
105
|
+
Groonga::Schema.define do |schema|
|
|
106
|
+
schema.create_table("Books", :type => :double_array_trie)
|
|
107
|
+
end
|
|
108
|
+
response = process(:table_list, {})
|
|
109
|
+
expected = [
|
|
110
|
+
TABLES_HEADER,
|
|
111
|
+
[256,
|
|
112
|
+
"Books",
|
|
113
|
+
@database_path.to_s + ".0000100",
|
|
114
|
+
"TABLE_DAT_KEY|PERSISTENT",
|
|
115
|
+
"ShortText",
|
|
116
|
+
nil,
|
|
117
|
+
nil,
|
|
118
|
+
nil],
|
|
119
|
+
]
|
|
120
|
+
assert_equal(expected, response.last)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_with_value_type
|
|
124
|
+
Groonga::Schema.define do |schema|
|
|
125
|
+
schema.create_table("BookIds", :type => :hash,
|
|
126
|
+
:key_type => "UInt32",
|
|
127
|
+
:value_type => "UInt32")
|
|
128
|
+
end
|
|
129
|
+
response = process(:table_list, {})
|
|
130
|
+
expected = [
|
|
131
|
+
TABLES_HEADER,
|
|
132
|
+
[256,
|
|
133
|
+
"BookIds",
|
|
134
|
+
@database_path.to_s + ".0000100",
|
|
135
|
+
"TABLE_HASH_KEY|PERSISTENT",
|
|
136
|
+
"UInt32",
|
|
137
|
+
"UInt32",
|
|
138
|
+
nil,
|
|
139
|
+
nil],
|
|
140
|
+
]
|
|
141
|
+
assert_equal(expected, response.last)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_with_default_tokenizer
|
|
145
|
+
Groonga::Schema.define do |schema|
|
|
146
|
+
schema.create_table("Books", :type => :hash,
|
|
147
|
+
:default_tokenizer => "TokenBigram")
|
|
148
|
+
end
|
|
149
|
+
response = process(:table_list, {})
|
|
150
|
+
expected = [
|
|
151
|
+
TABLES_HEADER,
|
|
152
|
+
[256,
|
|
153
|
+
"Books",
|
|
154
|
+
@database_path.to_s + ".0000100",
|
|
155
|
+
"TABLE_HASH_KEY|PERSISTENT",
|
|
156
|
+
"ShortText",
|
|
157
|
+
nil,
|
|
158
|
+
"TokenBigram",
|
|
159
|
+
nil],
|
|
160
|
+
]
|
|
161
|
+
assert_equal(expected, response.last)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def test_with_normalizer
|
|
165
|
+
Groonga::Schema.define do |schema|
|
|
166
|
+
schema.create_table("Books", :type => :hash,
|
|
167
|
+
:normalizer => "NormalizerAuto")
|
|
168
|
+
end
|
|
169
|
+
response = process(:table_list, {})
|
|
170
|
+
expected = [
|
|
171
|
+
TABLES_HEADER,
|
|
172
|
+
[256,
|
|
173
|
+
"Books",
|
|
174
|
+
@database_path.to_s + ".0000100",
|
|
175
|
+
"TABLE_HASH_KEY|PERSISTENT",
|
|
176
|
+
"ShortText",
|
|
177
|
+
nil,
|
|
178
|
+
nil,
|
|
179
|
+
"NormalizerAuto"],
|
|
180
|
+
]
|
|
181
|
+
assert_equal(expected, response.last)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
|
2
|
+
#
|
|
3
|
+
# This library is free software; you can redistribute it and/or
|
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
|
6
|
+
#
|
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
10
|
+
# Lesser General Public License for more details.
|
|
11
|
+
#
|
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
13
|
+
# License along with this library; if not, write to the Free Software
|
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15
|
+
|
|
16
|
+
class TableRemoveTest < GroongaHandlerTest
|
|
17
|
+
def create_handler
|
|
18
|
+
Droonga::Plugins::Groonga::TableRemove::Handler.new("droonga",
|
|
19
|
+
@handler.context,
|
|
20
|
+
@messenger,
|
|
21
|
+
@loop)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def setup
|
|
25
|
+
super
|
|
26
|
+
Groonga::Schema.define do |schema|
|
|
27
|
+
schema.create_table("Books", :type => :hash)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_success
|
|
32
|
+
response = process(:table_remove, {"name" => "Books"})
|
|
33
|
+
assert_equal(
|
|
34
|
+
[NORMALIZED_HEADER_SUCCESS, true],
|
|
35
|
+
[normalize_header(response.first), response.last]
|
|
36
|
+
)
|
|
37
|
+
assert_equal(<<-SCHEMA, dump)
|
|
38
|
+
SCHEMA
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_failure
|
|
42
|
+
response = process(:table_remove, {})
|
|
43
|
+
assert_equal(
|
|
44
|
+
[NORMALIZED_HEADER_INVALID_ARGUMENT, false],
|
|
45
|
+
[normalize_header(response.first), response.last]
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_remove
|
|
50
|
+
process(:table_remove, {"name" => "Books"})
|
|
51
|
+
assert_equal(<<-SCHEMA, dump)
|
|
52
|
+
SCHEMA
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_unknown_table
|
|
56
|
+
process(:table_remove, {"name" => "Unknown"})
|
|
57
|
+
assert_equal(<<-SCHEMA, dump)
|
|
58
|
+
table_create Books TABLE_HASH_KEY --key_type ShortText
|
|
59
|
+
SCHEMA
|
|
60
|
+
end
|
|
61
|
+
end
|