[Groonga-commit] droonga/fluent-plugin-droonga at 5098268 [master] Make farm's device required

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Feb 12 18:10:49 JST 2014


YUKI Hiroshi	2014-02-12 18:10:49 +0900 (Wed, 12 Feb 2014)

  New Revision: 5098268fac67f4a72b7f09a137aaca4423db3365
  https://github.com/droonga/fluent-plugin-droonga/commit/5098268fac67f4a72b7f09a137aaca4423db3365

  Message:
    Make farm's device required

  Modified files:
    lib/droonga/catalog/base.rb
    test/unit/catalog/test_version1.rb

  Modified: lib/droonga/catalog/base.rb (+2 -0)
===================================================================
--- lib/droonga/catalog/base.rb    2014-02-12 18:01:18 +0900 (9ad97d7)
+++ lib/droonga/catalog/base.rb    2014-02-12 18:10:49 +0900 (a59a983)
@@ -223,6 +223,8 @@ module Droonga
 
       def validate_farm(farm, name)
         validate_parameter_type(Hash, farm, name)
+
+        raise MissingRequiredParameter.new("#{name}.device", @path) unless farm["device"]
         validate_parameter_type(String, farm["device"], "#{name}.device")
       end
 

  Modified: test/unit/catalog/test_version1.rb (+49 -6)
===================================================================
--- test/unit/catalog/test_version1.rb    2014-02-12 18:01:18 +0900 (8c7b557)
+++ test/unit/catalog/test_version1.rb    2014-02-12 18:10:49 +0900 (a7686e6)
@@ -16,14 +16,20 @@
 require "droonga/catalog/version1"
 
 class CatalogTest < Test::Unit::TestCase
+  class << self
+    def minimum_data
+      {
+        "effective_date" => "2013-09-01T00:00:00Z",
+        "zones" => [],
+        "farms" => {},
+        "datasets" => {},
+      }
+    end
+  end
+
   private
   def minimum_data
-    {
-      "effective_date" => "2013-09-01T00:00:00Z",
-      "zones" => [],
-      "farms" => {},
-      "datasets" => {},
-    }
+    self.class.minimum_data
   end
 
   def create_catalog(data, path)
@@ -176,6 +182,20 @@ class CatalogTest < Test::Unit::TestCase
   end
 
   class ValidationTest < self
+    class << self
+      def farm_name
+        "localhost:23041/droonga"
+      end
+
+      def valid_farms
+        {
+          farm_name => {
+            "device" => ".",
+          },
+        }
+      end
+    end
+
     data(
       :missing_effective_date => {
         :catalog => {},
@@ -187,6 +207,29 @@ class CatalogTest < Test::Unit::TestCase
         },
         :error => Droonga::Catalog::InvalidDate,
       },
+      :missing_zones => {
+        :catalog => {
+          "effective_date" => minimum_data["effective_date"],
+        },
+        :error => Droonga::Catalog::MissingRequiredParameter,
+      },
+      :missing_farms => {
+        :catalog => {
+          "effective_date" => minimum_data["effective_date"],
+          "zones" => minimum_data["zones"],
+        },
+        :error => Droonga::Catalog::MissingRequiredParameter,
+      },
+      :no_device_farm => {
+        :catalog => {
+          "effective_date" => minimum_data["effective_date"],
+          "zones" => minimum_data["zones"],
+          "farms" => {
+            farm_name => {},
+          },
+        },
+        :error => Droonga::Catalog::MissingRequiredParameter,
+      },
     )
     def test_validation(data)
       assert_raise(data[:error]) do
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index