[Groonga-commit] groonga/groonga-command at 9a01b8c [master] Add Truncate#target_name

Back to archive index
Kouhei Sutou null+****@clear*****
Tue Oct 23 17:13:28 JST 2018


Kouhei Sutou	2018-10-23 17:13:28 +0900 (Tue, 23 Oct 2018)

  Revision: 9a01b8c320bab15c89caf0eb320e3d5077da3499
  https://github.com/groonga/groonga-command/commit/9a01b8c320bab15c89caf0eb320e3d5077da3499

  Message:
    Add Truncate#target_name

  Modified files:
    lib/groonga/command/truncate.rb
    test/command/test-truncate.rb

  Modified: lib/groonga/command/truncate.rb (+6 -3)
===================================================================
--- lib/groonga/command/truncate.rb    2018-08-16 15:25:13 +0900 (25db877)
+++ lib/groonga/command/truncate.rb    2018-10-23 17:13:28 +0900 (e2cc6bf)
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2012-2018  Kouhei Sutou <kou****@clear*****>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -28,12 +26,17 @@ module Groonga
 
         def parameter_names
           [
+            :target_name,
             :table,
           ]
         end
       end
 
       Command.register(command_name, self)
+
+      def target_name
+        @target_name ||= self[:target_name] || self[:table]
+      end
     end
   end
 end

  Modified: test/command/test-truncate.rb (+21 -6)
===================================================================
--- test/command/test-truncate.rb    2018-08-16 15:25:13 +0900 (2e9dbf6)
+++ test/command/test-truncate.rb    2018-10-23 17:13:28 +0900 (ac186b2)
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2012-2013  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2012-2018  Kouhei Sutou <kou****@clear*****>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -25,13 +23,30 @@ class TruncateCommandTest < Test::Unit::TestCase
 
   class ConstructorTest < self
     def test_ordered_arguments
-      table = "Users"
+      target_name = "Users"
 
-      command = truncate_command([], [table])
+      command = truncate_command([], [target_name])
       assert_equal({
-                     :table => table,
+                     :target_name => target_name,
                    },
                    command.arguments)
     end
   end
+
+  class TargetNameTest < self
+    def test_nil
+      command = truncate_command
+      assert_nil(command.target_name)
+    end
+
+    def test_specified
+      command = truncate_command(:target_name => "Users")
+      assert_equal("Users", command.target_name)
+    end
+
+    def test_table
+      command = truncate_command(:table => "Users")
+      assert_equal("Users", command.target_name)
+    end
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181023/2e1c4fb9/attachment-0001.html>


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