[Groonga-commit] droonga/droonga-engine at aa8713e [master] Add tests for mismatched key

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Dec 2 12:12:55 JST 2014


YUKI Hiroshi	2014-12-02 12:12:55 +0900 (Tue, 02 Dec 2014)

  New Revision: aa8713eb0dc19f3113d473937f0d592dc9819e60
  https://github.com/droonga/droonga-engine/commit/aa8713eb0dc19f3113d473937f0d592dc9819e60

  Message:
    Add tests for mismatched key

  Modified files:
    test/unit/plugins/crud/test_add.rb

  Modified: test/unit/plugins/crud/test_add.rb (+40 -0)
===================================================================
--- test/unit/plugins/crud/test_add.rb    2014-12-02 12:12:43 +0900 (c3f947e)
+++ test/unit/plugins/crud/test_add.rb    2014-12-02 12:12:55 +0900 (4e80cf4)
@@ -134,6 +134,46 @@ class CRUDAddHandlerTest < Test::Unit::TestCase
     end
   end
 
+  class MismatchedTypeKeyTest < self
+    class Acceptable < self
+      def test_integer_for_string
+        setup_table_with_key_type("ShortText")
+        request = {
+          "table"  => "Users",
+          "key"    => 1,
+          "values" => {},
+        }
+        response = process(request)
+        assert_equal(SUCCESS_RESPONSE_BODY, response)
+        table =****@worke*****["Users"]
+        assert_equal(["1"], table.collect(&:key))
+      end
+
+      def test_string_for_integer
+        setup_table_with_key_type("UInt32")
+        request = {
+          "table"  => "Users",
+          "key"    => "1",
+          "values" => {},
+        }
+        response = process(request)
+        assert_equal(SUCCESS_RESPONSE_BODY, response)
+        table =****@worke*****["Users"]
+        assert_equal([1], table.collect(&:key))
+      end
+    end
+
+    private
+    def setup_table_with_key_type(key_type)
+      Groonga::Schema.define do |schema|
+        schema.create_table("Users",
+                            :type => :hash,
+                            :key_type => key_type) do |table|
+        end
+      end
+    end
+  end
+
   class NoKeyTest < self
     def setup_schema
       Groonga::Schema.define do |schema|
-------------- next part --------------
HTML����������������������������...
Descargar 



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