[Groonga-commit] groonga/gcs [master] Localize fixture loading

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 11日 (水) 19:23:52 JST


Yoji SHIDARA	2012-07-11 19:23:52 +0900 (Wed, 11 Jul 2012)

  New Revision: 7d6131ff4e27c6e581dc163c2896e9632600bd26
  https://github.com/groonga/gcs/commit/7d6131ff4e27c6e581dc163c2896e9632600bd26

  Log:
    Localize fixture loading

  Modified files:
    test/search.test.js

  Modified: test/search.test.js (+194 -189)
===================================================================
--- test/search.test.js    2012-07-11 19:19:30 +0900 (32251d2)
+++ test/search.test.js    2012-07-11 19:23:52 +0900 (c6c80af)
@@ -11,8 +11,6 @@ suite('Search API', function() {
   setup(function() {
     temporaryDatabase = utils.createTemporaryDatabase();
     database = temporaryDatabase.get();
-    utils.loadDumpFile(database, __dirname + '/fixture/companies/ddl.grn');
-    utils.loadDumpFile(database, __dirname + '/fixture/companies/data.grn');
     server = utils.setupServer(database);
   });
 
@@ -42,70 +40,25 @@ suite('Search API', function() {
     });
   }
 
-  testSearch('/2011-02-01/search?q=Hongo',
-             'search-companies-00000000000000000000000000.localhost',
-    function(response, body, done) {
-      var actual = JSON.parse(body);
-      assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok');
-      actual.info['time-ms'] = 0; // always set 0 for test
-      var expected = { // FIXME
-        rank: '-text_relevance',
-        'match-expr': '',
-        hits: {
-          found: 1,
-          start: 0,
-          hit: [{
-            id: 'id3',
-            data: {
-              _id: [3],
-              _key: ['id3'],
-              address: ['Hongo, Tokyo, Japan'],
-              description: [''],
-              email_address: ['info****@clear*****'],
-              name: ['ClearCode Inc.'],
-              age: [3],
-              product: ['groonga']
-            }
-          }]
-        },
-        info: {
-          rid: '000000000000000000000000000000000000000000000000000000000000000',
-          'time-ms': 0, // always 0
-          'cpu-time-ms': 0
-        }
-      };
-      assert.deepEqual(actual, expected);
-      done();
-    }
-  );
+  suite('with fixture loaded', function() {
+    setup(function() {
+      utils.loadDumpFile(database, __dirname + '/fixture/companies/ddl.grn');
+      utils.loadDumpFile(database, __dirname + '/fixture/companies/data.grn');
+    });
 
-  testSearch('/2011-02-01/search?q=Tokyo',
-             'search-companies-00000000000000000000000000.localhost',
-    function(response, body, done) {
-      var actual = JSON.parse(body);
-      assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok');
-      actual.info['time-ms'] = 0; // always set 0 for test
-      var expected = {
-        rank: '-text_relevance',
-        'match-expr': '',
-        hits: {
-          found: 3,
-          start: 0,
-          hit: [
-            {
-              id: 'id1',
-              data: {
-                _id: [1],
-                _key: ['id1'],
-                address: ['Shibuya, Tokyo, Japan'],
-                description: [''],
-                email_address: ['info****@razil*****'],
-                name: ['Brazil'],
-                age: [1],
-                product: ['groonga']
-              }
-            },
-            {
+    testSearch('/2011-02-01/search?q=Hongo',
+               'search-companies-00000000000000000000000000.localhost',
+      function(response, body, done) {
+        var actual = JSON.parse(body);
+        assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok');
+        actual.info['time-ms'] = 0; // always set 0 for test
+        var expected = { // FIXME
+          rank: '-text_relevance',
+          'match-expr': '',
+          hits: {
+            found: 1,
+            start: 0,
+            hit: [{
               id: 'id3',
               data: {
                 _id: [3],
@@ -117,133 +70,185 @@ suite('Search API', function() {
                 age: [3],
                 product: ['groonga']
               }
-            },
-            {
-              id: 'id9',
-              data: {
-                _id: [9],
-                _key: ['id9'],
-                address: ['Tokyo, Japan'],
-                description: [''],
-                email_address: [''],
-                name: ['Umbrella Corporation'],
-                age: [9],
-                product: ['tyrant']
-              }
-            }
-          ]
-        },
-        info: {
-          rid: '000000000000000000000000000000000000000000000000000000000000000',
-          'time-ms': 0, // always 0
-          'cpu-time-ms': 0
-        }
-      };
-      assert.deepEqual(actual, expected);
-      done();
-    }
-  );
+            }]
+          },
+          info: {
+            rid: '000000000000000000000000000000000000000000000000000000000000000',
+            'time-ms': 0, // always 0
+            'cpu-time-ms': 0
+          }
+        };
+        assert.deepEqual(actual, expected);
+        done();
+      }
+    );
 
-  testSearch('/2011-02-01/search?q=Tokyo&size=2',
-             'search-companies-00000000000000000000000000.localhost',
-    function(response, body, done) {
-      var actual = JSON.parse(body);
-      assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok');
-      actual.info['time-ms'] = 0; // always set 0 for test
-      var expected = {
-        rank: '-text_relevance',
-        'match-expr': '',
-        hits: {
-          found: 3,
-          start: 0,
-          hit: [
-            {
-              id: 'id1',
-              data: {
-                _id: [1],
-                _key: ['id1'],
-                address: ['Shibuya, Tokyo, Japan'],
-                description: [''],
-                email_address: ['info****@razil*****'],
-                name: ['Brazil'],
-                age: [1],
-                product: ['groonga']
-              }
-            },
-            {
-              id: 'id3',
-              data: {
-                _id: [3],
-                _key: ['id3'],
-                address: ['Hongo, Tokyo, Japan'],
-                description: [''],
-                email_address: ['info****@clear*****'],
-                name: ['ClearCode Inc.'],
-                age: [3],
-                product: ['groonga']
+    testSearch('/2011-02-01/search?q=Tokyo',
+               'search-companies-00000000000000000000000000.localhost',
+      function(response, body, done) {
+        var actual = JSON.parse(body);
+        assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok');
+        actual.info['time-ms'] = 0; // always set 0 for test
+        var expected = {
+          rank: '-text_relevance',
+          'match-expr': '',
+          hits: {
+            found: 3,
+            start: 0,
+            hit: [
+              {
+                id: 'id1',
+                data: {
+                  _id: [1],
+                  _key: ['id1'],
+                  address: ['Shibuya, Tokyo, Japan'],
+                  description: [''],
+                  email_address: ['info****@razil*****'],
+                  name: ['Brazil'],
+                  age: [1],
+                  product: ['groonga']
+                }
+              },
+              {
+                id: 'id3',
+                data: {
+                  _id: [3],
+                  _key: ['id3'],
+                  address: ['Hongo, Tokyo, Japan'],
+                  description: [''],
+                  email_address: ['info****@clear*****'],
+                  name: ['ClearCode Inc.'],
+                  age: [3],
+                  product: ['groonga']
+                }
+              },
+              {
+                id: 'id9',
+                data: {
+                  _id: [9],
+                  _key: ['id9'],
+                  address: ['Tokyo, Japan'],
+                  description: [''],
+                  email_address: [''],
+                  name: ['Umbrella Corporation'],
+                  age: [9],
+                  product: ['tyrant']
+                }
               }
-            }
-          ]
-        },
-        info: {
-          rid: '000000000000000000000000000000000000000000000000000000000000000',
-          'time-ms': 0, // always 0
-          'cpu-time-ms': 0
-        }
-      };
-      assert.deepEqual(actual, expected);
-      done();
-    }
-  );
+            ]
+          },
+          info: {
+            rid: '000000000000000000000000000000000000000000000000000000000000000',
+            'time-ms': 0, // always 0
+            'cpu-time-ms': 0
+          }
+        };
+        assert.deepEqual(actual, expected);
+        done();
+      }
+    );
 
-  testSearch('/2011-02-01/search?q=Tokyo&start=1',
-             'search-companies-00000000000000000000000000.localhost',
-    function(response, body, done) {
-      var actual = JSON.parse(body);
-      actual.info['time-ms'] = 0; // always set 0 for test
-      var expected = {
-        rank: '-text_relevance',
-        'match-expr': '',
-        hits: {
-          found: 3,
-          start: 1,
-          hit: [
-            {
-              id: 'id3',
-              data: {
-                _id: [3],
-                _key: ['id3'],
-                address: ['Hongo, Tokyo, Japan'],
-                description: [''],
-                email_address: ['info****@clear*****'],
-                name: ['ClearCode Inc.'],
-                age: [3],
-                product: ['groonga']
+    testSearch('/2011-02-01/search?q=Tokyo&size=2',
+               'search-companies-00000000000000000000000000.localhost',
+      function(response, body, done) {
+        var actual = JSON.parse(body);
+        assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok');
+        actual.info['time-ms'] = 0; // always set 0 for test
+        var expected = {
+          rank: '-text_relevance',
+          'match-expr': '',
+          hits: {
+            found: 3,
+            start: 0,
+            hit: [
+              {
+                id: 'id1',
+                data: {
+                  _id: [1],
+                  _key: ['id1'],
+                  address: ['Shibuya, Tokyo, Japan'],
+                  description: [''],
+                  email_address: ['info****@razil*****'],
+                  name: ['Brazil'],
+                  age: [1],
+                  product: ['groonga']
+                }
+              },
+              {
+                id: 'id3',
+                data: {
+                  _id: [3],
+                  _key: ['id3'],
+                  address: ['Hongo, Tokyo, Japan'],
+                  description: [''],
+                  email_address: ['info****@clear*****'],
+                  name: ['ClearCode Inc.'],
+                  age: [3],
+                  product: ['groonga']
+                }
               }
-            },
-            {
-              id: 'id9',
-              data: {
-                _id: [9],
-                _key: ['id9'],
-                address: ['Tokyo, Japan'],
-                description: [''],
-                email_address: [''],
-                name: ['Umbrella Corporation'],
-                age: [9],
-                product: ['tyrant']
+            ]
+          },
+          info: {
+            rid: '000000000000000000000000000000000000000000000000000000000000000',
+            'time-ms': 0, // always 0
+            'cpu-time-ms': 0
+          }
+        };
+        assert.deepEqual(actual, expected);
+        done();
+      }
+    );
+
+    testSearch('/2011-02-01/search?q=Tokyo&start=1',
+               'search-companies-00000000000000000000000000.localhost',
+      function(response, body, done) {
+        var actual = JSON.parse(body);
+        actual.info['time-ms'] = 0; // always set 0 for test
+        var expected = {
+          rank: '-text_relevance',
+          'match-expr': '',
+          hits: {
+            found: 3,
+            start: 1,
+            hit: [
+              {
+                id: 'id3',
+                data: {
+                  _id: [3],
+                  _key: ['id3'],
+                  address: ['Hongo, Tokyo, Japan'],
+                  description: [''],
+                  email_address: ['info****@clear*****'],
+                  name: ['ClearCode Inc.'],
+                  age: [3],
+                  product: ['groonga']
+                }
+              },
+              {
+                id: 'id9',
+                data: {
+                  _id: [9],
+                  _key: ['id9'],
+                  address: ['Tokyo, Japan'],
+                  description: [''],
+                  email_address: [''],
+                  name: ['Umbrella Corporation'],
+                  age: [9],
+                  product: ['tyrant']
+                }
               }
-            }
-          ]
-        },
-        info: {
-          rid: '000000000000000000000000000000000000000000000000000000000000000',
-          'time-ms': 0, // always 0
-          'cpu-time-ms': 0
-        }
-      };
-      assert.deepEqual(actual, expected);
-      done();
-    }
-  );
+            ]
+          },
+          info: {
+            rid: '000000000000000000000000000000000000000000000000000000000000000',
+            'time-ms': 0, // always 0
+            'cpu-time-ms': 0
+          }
+        };
+        assert.deepEqual(actual, expected);
+        done();
+      }
+    );
+  });
 });
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index