[Groonga-commit] droonga/droonga-engine at 44a570e [master] test: Add test for Groonga's delete command

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Apr 24 13:21:20 JST 2014


YUKI Hiroshi	2014-04-24 13:21:20 +0900 (Thu, 24 Apr 2014)

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

  Message:
    test: Add test for Groonga's delete command

  Added files:
    test/unit/plugins/groonga/test_delete.rb

  Added: test/unit/plugins/groonga/test_delete.rb (+107 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/plugins/groonga/test_delete.rb    2014-04-24 13:21:20 +0900 (03ff9fb)
@@ -0,0 +1,107 @@
+# Copyright (C) 2014 Droonga Project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+class DeleteTest < GroongaHandlerTest
+  def create_handler
+    Droonga::Plugins::Groonga::Delete::Handler.new("droonga",
+                                                   @handler.context,
+                                                   @messages,
+                                                   @loop)
+  end
+
+  def test_success
+    Groonga::Schema.define(:context => @context) do |schema|
+      schema.create_table("Books", :type => :hash)
+    end
+    @context["Books"].add("sample")
+    message = {
+      "table" => "Books",
+      "key"   => "sample",
+    }
+    response = process(:delete, message)
+    assert_equal(
+      [NORMALIZED_HEADER_SUCCESS, true],
+      [normalize_header(response.first), response.last]
+    )
+  end
+
+  def test_unknown_table
+    message = {
+      "table" => "Unknown",
+    }
+    response = process(:delete, message)
+    assert_equal(
+      [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
+      [normalize_header(response.first), response.last]
+    )
+  end
+
+  def test_no_identifier
+    Groonga::Schema.define(:context => @context) do |schema|
+      schema.create_table("Books", :type => :hash)
+    end
+    message = {
+      "table" => "Books",
+    }
+    response = process(:delete, message)
+    assert_equal(
+      [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
+      [normalize_header(response.first), response.last]
+    )
+  end
+
+  data(:key_and_id => { "key" => "key", "id" => 1 },
+       :id_and_filter => { "id" => 1, "filter" => "filter" },
+       :key_and_filter => { "key" => "key", "filter" => "filter" })
+  def test_duplicated_identifier(data)
+    Groonga::Schema.define(:context => @context) do |schema|
+      schema.create_table("Books", :type => :hash)
+    end
+    message = {
+      "table" => "Books",
+    }.merge(data)
+    response = process(:delete, message)
+    assert_equal(
+      [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
+      [normalize_header(response.first), response.last]
+    )
+  end
+
+  class DeleteTest < self
+    def test_key
+      Groonga::Schema.define(:context => @context) do |schema|
+        schema.create_table("Books", :type => :hash)
+      end
+      @context["Books"].add("sample")
+      process(:delete,
+              {"table" => "Books", "key" => "sample"})
+      assert_equal(<<-DUMP, dump)
+table_create Books TABLE_HASH_KEY --key_type ShortText
+      DUMP
+    end
+
+    def test_id
+      Groonga::Schema.define(:context => @context) do |schema|
+        schema.create_table("Ages", :type => :array)
+      end
+      @context["Ages"].add(10)
+      process(:delete,
+              {"table" => "Ages", "id" => 1})
+      assert_equal(<<-DUMP, dump)
+table_create Books TABLE_HASH_KEY --key_type ShortText
+      DUMP
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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