[Groonga-commit] droonga/fluent-plugin-droonga at 73d97c1 [master] Split fixture into two: for hash and for array

Back to archive index

Yoji Shidara null+****@clear*****
Thu Nov 28 13:58:00 JST 2013


Yoji Shidara	2013-11-28 13:58:00 +0900 (Thu, 28 Nov 2013)

  New Revision: 73d97c1de2584a59c8ad67e2f39f8f568138a4f0
  https://github.com/droonga/fluent-plugin-droonga/commit/73d97c1de2584a59c8ad67e2f39f8f568138a4f0

  Merged 4e131bb: Merge pull request #33 from droonga/add-test-for-search-with-reference-to-array-revised

  Message:
    Split fixture into two: for hash and for array

  Added files:
    test/unit/fixtures/array.grn
    test/unit/fixtures/reference/array.grn
    test/unit/fixtures/reference/hash.grn
  Removed files:
    test/unit/fixtures/reference.grn
  Modified files:
    test/unit/plugin/handler/test_search.rb

  Added: test/unit/fixtures/array.grn (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/fixtures/array.grn    2013-11-28 13:58:00 +0900 (f662733)
@@ -0,0 +1,18 @@
+table_create DocumentsArray TABLE_NO_KEY
+column_create DocumentsArray title COLUMN_SCALAR ShortText
+
+load --table DocumentsArray
+[
+{"title": "Groonga"}
+]
+
+
+table_create SectionsForArray TABLE_HASH_KEY ShortText
+column_create SectionsForArray title COLUMN_SCALAR ShortText
+column_create SectionsForArray document COLUMN_SCALAR DocumentsArray
+load --table SectionsForArray
+[
+{"_key": "1.1", "title": "Groonga overview", "document": 1},
+{"_key": "1.2", "title": "Full text search and Instant update", "document": 1},
+{"_key": "1.3", "title": "Column store and aggregate query", "document": 1}
+]

  Deleted: test/unit/fixtures/reference.grn (+0 -38) 100644
===================================================================
--- test/unit/fixtures/reference.grn    2013-11-28 11:38:59 +0900 (f3d5490)
+++ /dev/null
@@ -1,38 +0,0 @@
-table_create DocumentsHash TABLE_HASH_KEY ShortText
-column_create DocumentsHash title COLUMN_SCALAR ShortText
-
-load --table DocumentsHash
-[
-{"_key": "Groonga", "title": "Groonga"}
-]
-
-
-table_create SectionsForHash TABLE_HASH_KEY ShortText
-column_create SectionsForHash title COLUMN_SCALAR ShortText
-column_create SectionsForHash document COLUMN_SCALAR DocumentsHash
-load --table SectionsForHash
-[
-{"_key": "1.1", "title": "Groonga overview", "document": "Groonga"},
-{"_key": "1.2", "title": "Full text search and Instant update", "document": "Groonga"},
-{"_key": "1.3", "title": "Column store and aggregate query", "document": "Groonga"}
-]
-
-
-table_create DocumentsArray TABLE_NO_KEY
-column_create DocumentsArray title COLUMN_SCALAR ShortText
-
-load --table DocumentsArray
-[
-{"title": "Groonga"}
-]
-
-
-table_create SectionsForArray TABLE_HASH_KEY ShortText
-column_create SectionsForArray title COLUMN_SCALAR ShortText
-column_create SectionsForArray document COLUMN_SCALAR DocumentsArray
-load --table SectionsForArray
-[
-{"_key": "1.1", "title": "Groonga overview", "document": 1},
-{"_key": "1.2", "title": "Full text search and Instant update", "document": 1},
-{"_key": "1.3", "title": "Column store and aggregate query", "document": 1}
-]

  Added: test/unit/fixtures/reference/array.grn (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/fixtures/reference/array.grn    2013-11-28 13:58:00 +0900 (dc3a9a9)
@@ -0,0 +1,11 @@
+
+
+table_create SectionsForHash TABLE_HASH_KEY ShortText
+column_create SectionsForHash title COLUMN_SCALAR ShortText
+column_create SectionsForHash document COLUMN_SCALAR DocumentsHash
+load --table SectionsForHash
+[
+{"_key": "1.1", "title": "Groonga overview", "document": "Groonga"},
+{"_key": "1.2", "title": "Full text search and Instant update", "document": "Groonga"},
+{"_key": "1.3", "title": "Column store and aggregate query", "document": "Groonga"}
+]

  Added: test/unit/fixtures/reference/hash.grn (+7 -0) 100644
===================================================================
--- /dev/null
+++ test/unit/fixtures/reference/hash.grn    2013-11-28 13:58:00 +0900 (2c76472)
@@ -0,0 +1,7 @@
+table_create DocumentsHash TABLE_HASH_KEY ShortText
+column_create DocumentsHash title COLUMN_SCALAR ShortText
+
+load --table DocumentsHash
+[
+{"_key": "Groonga", "title": "Groonga"}
+]

  Modified: test/unit/plugin/handler/test_search.rb (+79 -69)
===================================================================
--- test/unit/plugin/handler/test_search.rb    2013-11-28 11:38:59 +0900 (9aafa77)
+++ test/unit/plugin/handler/test_search.rb    2013-11-28 13:58:00 +0900 (418c0dc)
@@ -508,84 +508,94 @@ class SearchHandlerTest < Test::Unit::TestCase
   end
 
   class ReferenceTest < self
-    def setup
-      super
-      restore(fixture_data("reference.grn"))
-      setup_plugin(Droonga::SearchHandler)
-    end
+    class Hash
+      def setup
+        super
+        restore(fixture_data("reference/hash.grn"))
+        setup_plugin(Droonga::SearchHandler)
+      end
 
-    def test_reference_to_hash
-      expected = {
-        "sections-result" => {
-          "records" => [
-            {
-              "_key" => "1.1",
-              "document" => "Groonga",
-            },
-            {
-              "_key" => "1.2",
-              "document" => "Groonga",
-            },
-            {
-              "_key" => "1.3",
-              "document" => "Groonga",
-            },
-          ],
-        },
-      }
-      request = {
-        "queries" => {
+      def test_reference_to_hash
+        expected = {
           "sections-result" => {
-            "source" => "SectionsForHash",
-            "output" => {
-              "elements" => [
-                "records",
-              ],
-              "format" => "complex",
-              "limit" => 3,
-              "attributes" => ["_key", "document"],
+            "records" => [
+              {
+                "_key" => "1.1",
+                "document" => "Groonga",
+              },
+              {
+                "_key" => "1.2",
+                "document" => "Groonga",
+              },
+              {
+                "_key" => "1.3",
+                "document" => "Groonga",
+              },
+            ],
+          },
+        }
+        request = {
+          "queries" => {
+            "sections-result" => {
+              "source" => "SectionsForHash",
+              "output" => {
+                "elements" => [
+                  "records",
+                ],
+                "format" => "complex",
+                "limit" => 3,
+                "attributes" => ["_key", "document"],
+              },
             },
           },
-        },
-      }
-      assert_search(expected, request)
+        }
+        assert_search(expected, request)
+      end
     end
 
-    def test_reference_to_array
-      expected = {
-        "sections-result" => {
-          "records" => [
-            {
-              "_key" => "1.1",
-              "document" => 1,
-            },
-            {
-              "_key" => "1.2",
-              "document" => 1,
-            },
-            {
-              "_key" => "1.3",
-              "document" => 1,
-            },
-          ],
-        },
-      }
-      request = {
-        "queries" => {
+    class Array
+      def setup
+        super
+        restore(fixture_data("reference/array.grn"))
+        setup_plugin(Droonga::SearchHandler)
+      end
+
+      def test_reference_to_array
+        expected = {
           "sections-result" => {
-            "source" => "SectionsForArray",
-            "output" => {
-              "elements" => [
-                "records",
-              ],
-              "format" => "complex",
-              "limit" => 3,
-              "attributes" => ["_key", "document"],
+            "records" => [
+              {
+                "_key" => "1.1",
+                "document" => 1,
+              },
+              {
+                "_key" => "1.2",
+                "document" => 1,
+              },
+              {
+                "_key" => "1.3",
+                "document" => 1,
+              },
+            ],
+          },
+        }
+        request = {
+          "queries" => {
+            "sections-result" => {
+              "source" => "SectionsForArray",
+              "output" => {
+                "elements" => [
+                  "records",
+                ],
+                "format" => "complex",
+                "limit" => 3,
+                "attributes" => ["_key", "document"],
+              },
             },
           },
-        },
-      }
-      assert_search(expected, request)
+        }
+        assert_search(expected, request)
+      end
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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