YUKI Hiroshi
null+****@clear*****
Wed Feb 12 19:13:00 JST 2014
YUKI Hiroshi 2014-02-12 19:13:00 +0900 (Wed, 12 Feb 2014) New Revision: c48a991cd73e1ba4a10eb460704ca7f6b7c942b3 https://github.com/droonga/fluent-plugin-droonga/commit/c48a991cd73e1ba4a10eb460704ca7f6b7c942b3 Message: Make plugins optional Modified files: lib/droonga/catalog/base.rb test/unit/catalog/test_version1.rb Modified: lib/droonga/catalog/base.rb (+7 -1) =================================================================== --- lib/droonga/catalog/base.rb 2014-02-12 19:01:29 +0900 (3310329) +++ lib/droonga/catalog/base.rb 2014-02-12 19:13:00 +0900 (1999836) @@ -298,7 +298,7 @@ module Droonga end do_validation do - validate_parameter_type(Array, dataset["plugins"], "#{name}.plugins") + validate_plugins(dataset["plugins"], "#{name}.plugins") end end @@ -340,6 +340,12 @@ module Droonga end end + def validate_plugins(plugins, name) + return unless plugins + validate_required_parameter(plugins, name) + validate_parameter_type(Array, plugins, "#{name}.plugins") + end + def validate_database_relations return unless @data["farms"] Modified: test/unit/catalog/test_version1.rb (+30 -2) =================================================================== --- test/unit/catalog/test_version1.rb 2014-02-12 19:01:29 +0900 (f8b11ae) +++ test/unit/catalog/test_version1.rb 2014-02-12 19:13:00 +0900 (54e844f) @@ -216,13 +216,41 @@ class CatalogTest < Test::Unit::TestCase Droonga::Catalog::MissingRequiredParameter.new("datasets", path), ], }, + :invalid_farms => { + :catalog => minimum_data.merge( + "farms" => { + farm_name => { + }, + }, + ), + :errors => [ + Droonga::Catalog::MissingRequiredParameter.new("farms.#{farm_name}.device", path), + ], + }, + :missing_dataset_parameters => { + :catalog => minimum_data.merge( + "farms" => valid_farms, + "datasets" => { + "Droonga" => { + }, + }, + ), + :errors => [ + Droonga::Catalog::MissingRequiredParameter.new("datasets.Droonga.workers", path), + Droonga::Catalog::MissingRequiredParameter.new("datasets.Droonga.number_of_replicas", path), + Droonga::Catalog::MissingRequiredParameter.new("datasets.Droonga.number_of_partitions", path), + Droonga::Catalog::MissingRequiredParameter.new("datasets.Droonga.partition_key", path), + Droonga::Catalog::MissingRequiredParameter.new("datasets.Droonga.date_range", path), + Droonga::Catalog::MissingRequiredParameter.new("datasets.Droonga.ring", path), + ], + }, ) def test_validation(data) begin create_catalog(data[:catalog], "path/to/catalog") assert_nil("must not reach here") - rescue Droonga::MultiplexError => errors - actual_errors = errors.errors.collect do |error| + rescue Droonga::MultiplexError => actual_errors + actual_errors = actual_errors.errors.collect do |error| error.message end.sort expected_errors = data[:errors].collect do |error| -------------- next part -------------- HTML����������������������������...Download