[Groonga-commit] groonga/gcs [master] Give arguments to new Domain() as a hash instead of flat list

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Dec 6 19:23:41 JST 2012


YUKI Hiroshi	2012-12-06 19:23:41 +0900 (Thu, 06 Dec 2012)

  New Revision: 72b7595639595132d5b039e5259a2b7dc5b8a260
  https://github.com/groonga/gcs/commit/72b7595639595132d5b039e5259a2b7dc5b8a260

  Log:
    Give arguments to new Domain() as a hash instead of flat list

  Modified files:
    bin/gcs
    lib/api/2011-02-01/batch.js
    lib/api/2011-02-01/configuration.js
    lib/batch/processor.js
    lib/command-line.js
    lib/database/domain.js
    lib/select-query.js
    test/api-configuration.test.js
    test/api-search.test.js
    test/bq-translator.test.js
    test/database-domain.test.js
    test/database-index-field.test.js
    test/gcs-commands.test.js

  Modified: bin/gcs (+8 -0)
===================================================================
--- bin/gcs    2012-12-06 18:23:16 +0900 (6c90e5f)
+++ bin/gcs    2012-12-06 19:23:41 +0900 (a55a80f)
@@ -11,6 +11,12 @@ commandLine
             '[' + CLI.defaultDatabasePath + ']',
           String,
           CLI.defaultDatabasePath)
+  .option('--documents-path <path>',
+          'documents path' +
+            '(GCS_DOCUMENTS_PATH) ' +
+            '[' + CLI.defaultDocumentsPath + ']',
+          String,
+          CLI.defaultDocumentsPath)
   .option('-p, --port <port>',
           'The port number assigned to the service' +
             '(GCS_PORT) ' +
@@ -45,6 +51,7 @@ commandLine
 
 var server = gcsServer.createServer({
       databasePath:      commandLine.options.databasePath,
+      documentsPath:     commandLine.options.documentsPath,
       accessLogPath:     commandLine.options.accessLogPath,
       queryLogPath:      commandLine.options.queryLogPath,
       errorLogPath:      commandLine.options.errorLogPath,
@@ -56,5 +63,6 @@ var server = gcsServer.createServer({
 server.listen(commandLine.port, function() {
   console.log('gcs listening at %d', commandLine.port);
   console.log('database is at %s', commandLine.options.databasePath);
+  console.log('documents are stored into %s', commandLine.options.documentsPath);
   console.log('privileged IP ranges are %s', commandLine.options.privilege);
 });

  Modified: lib/api/2011-02-01/batch.js (+3 -1)
===================================================================
--- lib/api/2011-02-01/batch.js    2012-12-06 18:23:16 +0900 (af93788)
+++ lib/api/2011-02-01/batch.js    2012-12-06 19:23:41 +0900 (139dbbc)
@@ -45,7 +45,9 @@ exports.createHandler = function(context, config) {
     if (handleInvalidContentLength(request, response)) return;
 
     var batches = request.body;
-    var domain = new Domain(request, context);
+    var domain = new Domain({ source:        request,
+                              context:       context,
+                              documentsPath: config.documentsPath);
     var processor = new BatchProcessor({
           context: context,
           domain: domain

  Modified: lib/api/2011-02-01/configuration.js (+22 -11)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-12-06 18:23:16 +0900 (9406f8f)
+++ lib/api/2011-02-01/configuration.js    2012-12-06 19:23:41 +0900 (b710940)
@@ -142,7 +142,8 @@ function createDomainStatus(options) {
 
 handlers.CreateDomain = function(context, request, response, config) {
   var domain = handleDomanValidationError(function() {
-        return new Domain(request.query.DomainName || '', context).validate();
+        return new Domain({ name:    request.query.DomainName || '',
+                            context: context }).validate();
       });
   domain.saveSync();
   var result = createDomainStatus({
@@ -154,7 +155,8 @@ handlers.CreateDomain = function(context, request, response, config) {
 
 handlers.DeleteDomain = function(context, request, response, config) {
   var domain = handleDomanValidationError(function() {
-        return new Domain(request.query.DomainName || '', context).validate();
+        return new Domain({ name:    request.query.DomainName || '',
+                            context: context }).validate();
       });
   var result;
   if (domain.exists()) {
@@ -199,7 +201,8 @@ handlers.DescribeDomains = function(context, request, response, config) {
   var domains = domainNames.length ?
                   domainNames.map(function(name) {
                     try {
-                      var domain = new Domain(name, context);
+                      var domain = new Domain({ name:    name,
+                                                context: context });
                       return domain.exists() ? domain : null;
                     } catch(error) {
                       return null;
@@ -303,7 +306,8 @@ handlers.DefineIndexField = function(context, request, response, config) {
   var domain;
   try {
     handleDomanValidationError(function() {
-      domain = new Domain(domainName, context);
+      domain = new Domain({ name:    domainName,
+                            context: context });
       domain.validate();
     });
   } catch(error) {
@@ -384,7 +388,8 @@ handlers.DeleteIndexField = function(context, request, response, config) {
   var domain;
   try {
     handleDomanValidationError(function() {
-      domain = new Domain(domainName, context);
+      domain = new Domain({ name:    domainName,
+                            context: context });
       domain.validate();
     });
   } catch(error) {
@@ -449,7 +454,8 @@ function createIndexFields(fields) {
 
 handlers.DescribeIndexFields = function(context, request, response, config) {
   var domain = handleDomanValidationError(function() {
-        return new Domain(request.query.DomainName || '', context).validate();
+        return new Domain({ name:    request.query.DomainName,
+                            context: context }).validate();
       });
 
   var keys = Object.keys(request.query).filter(function(key) {
@@ -505,7 +511,8 @@ function createFieldNames(domain) {
 }
 
 handlers.IndexDocuments = function(context, request, response, config) {
-  var domain = new Domain(request.query.DomainName, context);
+  var domain = new Domain({ name:    request.query.DomainName,
+                            context: context });
   domain.reindexSync();
   var result = createFieldNames(domain);
   response.contentType('application/xml');
@@ -530,7 +537,8 @@ function createSynonymOptionsStatus(options) {
 }
 
 handlers.UpdateSynonymOptions = function(context, request, response, config) {
-  var domain = new Domain(request.query.DomainName, context);
+  var domain = new Domain({ name:    request.query.DomainName,
+                            context: context });
   var synonymOptionsJson = request.query.Synonyms;
   var synonymOptions = JSON.parse(synonymOptionsJson);
   domain.updateSynonymsSync(synonymOptions.synonyms);
@@ -545,7 +553,8 @@ handlers.UpdateSynonymOptions = function(context, request, response, config) {
 };
 
 handlers.DescribeSynonymOptions = function(context, request, response, config) {
-  var domain = new Domain(request.query.DomainName, context);
+  var domain = new Domain({ name:    request.query.DomainName,
+                            context: context });
   var result = createSynonymOptionsStatus({
         domain:    domain,
         updatedAt: domain.getOptionCreationDate('synonyms'),
@@ -570,7 +579,8 @@ function createDefaultSearchFieldStatus(options) {
 }
 
 handlers.UpdateDefaultSearchField = function(context, request, response, config) {
-  var domain = new Domain(request.query.DomainName, context);
+  var domain = new Domain({ name:    request.query.DomainName,
+                            context: context });
   var fieldName = request.query.DefaultSearchField;
   domain.defaultSearchField = fieldName;
 
@@ -584,7 +594,8 @@ handlers.UpdateDefaultSearchField = function(context, request, response, config)
 };
 
 handlers.DescribeDefaultSearchField = function(context, request, response, config) {
-  var domain = new Domain(request.query.DomainName, context);
+  var domain = new Domain({ name:    request.query.DomainName,
+                            context: context });
   var field = domain.defaultSearchField;
   var result = createDefaultSearchFieldStatus({
         fieldName: field ? field.name : '',

  Modified: lib/batch/processor.js (+2 -1)
===================================================================
--- lib/batch/processor.js    2012-12-06 18:23:16 +0900 (0fe2a39)
+++ lib/batch/processor.js    2012-12-06 19:23:41 +0900 (415c9f0)
@@ -7,7 +7,8 @@ exports.INVALID_BATCH = Processor.INVALID_BATCH = 'Invalid Batch';
 function Processor(options) {
   this.context = options.context || null;
   this.databasePath = options.databasePath;
-  this.domain = new Domain(options.domainName || options.domain, this.context);
+  this.domain = new Domain({ name:    options.domainName || options.domain,
+                             context: this.context });
   this.initialize();
 }
 

  Modified: lib/command-line.js (+4 -0)
===================================================================
--- lib/command-line.js    2012-12-06 18:23:16 +0900 (b2424a6)
+++ lib/command-line.js    2012-12-06 19:23:41 +0900 (154a51c)
@@ -74,6 +74,10 @@ CommandLineInterface.prototype = {
     return this.options.databasePath || defaultDatabasePath;
   },
 
+  get documentsPath() {
+    return this.options.documentsPath || defaultDocumentsPath;
+  },
+
   get options() {
     return this.program;
   },

  Modified: lib/database/domain.js (+18 -23)
===================================================================
--- lib/database/domain.js    2012-12-06 18:23:16 +0900 (c207c49)
+++ lib/database/domain.js    2012-12-06 19:23:41 +0900 (bcf1e75)
@@ -93,35 +93,29 @@ function assertValidDomainName(domain) {
     throw new MultiplexedValidationError(errors);
 }
 
-
-// Accepts two arguments: source and context.
-// You can give them in the reversed order, like:
-// new Domain("source", context) or new Domain(context, "source")
-function Domain() {
-  var source, context;
-  for (var i = 0, maxi = arguments.length, argument; i < maxi; i++) {
-    argument = arguments[i];
-    if (argument === null || argument === undefined)
-      continue;
-    if (argument instanceof nroonga.Context ||
-        argument instanceof nativeNroonga.Database) {
-      context = argument;
-    } else {
-      source = argument;
-    }
+function Domain(args) {
+  if (typeof args == 'string') {
+    args = {
+      source:        args,
+      context:       null,
+      documentsPath: null
+    };
   }
 
-  if (source instanceof Domain)
-    return source;
+  if ('name' in args && !('source' in args))
+    args.source = args.name;
+
+  if (args.source instanceof Domain)
+    return args.source;
 
-  this.initialize(source, context);
+  this.initialize(args);
 }
 Domain.prototype = {
-  initialize: function(source, context) {
+  initialize: function(args) {
     this.cachedIndexFields = {};
 
-    this.context = context && new nroonga.Context(context);
-    this.initializeNameAndId(source);
+    this.context = args.context && new nroonga.Context(args.context);
+    this.initializeNameAndId(args.source);
   },
   initializeNameAndId: function(source) {
     if (typeof source == 'string') {
@@ -682,7 +676,8 @@ Domain.getAll = function(context) {
     var match = table.name.match(tableMatcher);
     if (match) {
       var name = Domain.toDonamName(match[1]);
-      domains.push(new Domain(name, context));
+      domains.push(new Domain({ name: name,
+                                context: context }));
     }
   });
   domains.sort(function(a, b) { return a.name - b.name; });

  Modified: lib/select-query.js (+2 -1)
===================================================================
--- lib/select-query.js    2012-12-06 18:23:16 +0900 (ccf181a)
+++ lib/select-query.js    2012-12-06 19:23:41 +0900 (69a8685)
@@ -8,7 +8,8 @@ function translateQueryToBooleanQuery(query) {
 // this should be re-implemented as a class
 function SelectQuery(request, context) {
   this.request = request;
-  this.domain = new Domain(request, context);
+  this.domain = new Domain({ source: request,
+                             context: context });
 
   this.filters         = [];
   this.matchExpression = '';

  Modified: test/api-configuration.test.js (+8 -8)
===================================================================
--- test/api-configuration.test.js    2012-12-06 18:23:16 +0900 (cffb747)
+++ test/api-configuration.test.js    2012-12-06 19:23:41 +0900 (2355c68)
@@ -33,7 +33,7 @@ suite('Configuration API', function() {
       utils
         .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
         .next(function(response) {
-          assert.isTrue(new Domain('companies', context).exists());
+          assert.isTrue(new Domain({ name: 'companies', context: context }).exists());
           done();
         })
         .error(function(error) {
@@ -45,7 +45,7 @@ suite('Configuration API', function() {
       utils
         .get('/?DomainName=a&Action=CreateDomain&Version=2011-02-01')
         .next(function(response) {
-          assert.isFalse(new Domain('companies', context).exists());
+          assert.isFalse(new Domain({ name: 'companies', context: context }).exists());
           done();
         })
         .error(function(error) {
@@ -58,7 +58,7 @@ suite('Configuration API', function() {
         .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
         .get('/?DomainName=companies&Action=DeleteDomain&Version=2011-02-01')
         .next(function(response) {
-          assert.isFalse(new Domain('companies', context).exists());
+          assert.isFalse(new Domain({ name: 'companies', context: context }).exists());
           done();
         })
         .error(function(error) {
@@ -101,7 +101,7 @@ suite('Configuration API', function() {
              'IndexField.IndexFieldType=text&' +
              'Action=DefineIndexField&Version=2011-02-01')
         .next(function(response) {
-          var domain = new Domain('companies', context);
+          var domain = new Domain({ name: 'companies', context: context });
           var field = domain.getIndexField('name');
           assert.isTrue(field.exists(), response.body);
           done();
@@ -124,7 +124,7 @@ suite('Configuration API', function() {
              'IndexField.IndexFieldType=text&' +
              'Action=DefineIndexField&Version=2011-02-01')
         .next(function() {
-          domain = new Domain('companies', context);
+          domain = new Domain({ name: 'companies', context: context });
           field = domain.getIndexField('name');
         })
         .get('/?DomainName=companies&IndexFieldName=name&' +
@@ -159,7 +159,7 @@ suite('Configuration API', function() {
       utils
         .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
         .next(function() {
-          domain = new Domain('companies', context);
+          domain = new Domain({ name: 'companies', context: context });
           assert.isFalse(domain.hasSynonymsTableSync());
         })
         .get('/?Version=2011-02-01&Action=UpdateSynonymOptions&' +
@@ -257,7 +257,7 @@ suite('Configuration API', function() {
                'IndexField.IndexFieldName=name&IndexField.IndexFieldType=text&' +
                'Action=DefineIndexField&Version=2011-02-01')
         .next(function() {
-          domain = new Domain('companies', context);
+          domain = new Domain({ name: 'companies', context: context });
           assert.isTrue(domain.defaultSearchField === null,
                         domain.defaultSearchField);
         })
@@ -361,7 +361,7 @@ suite('Configuration API', function() {
         .get('/?DomainName=companies&' +
              'Action=IndexDocuments&Version=2011-02-01')
         .next(function(response) {
-          var domain = new Domain('companies', context);
+          var domain = new Domain({ name: 'companies', context: context });
           assert.isTrue(domain.exists());
           assert.isTrue(domain.getIndexField('name').exists());
           assert.isTrue(domain.getIndexField('age').exists());

  Modified: test/api-search.test.js (+1 -1)
===================================================================
--- test/api-search.test.js    2012-12-06 18:23:16 +0900 (796b150)
+++ test/api-search.test.js    2012-12-06 19:23:41 +0900 (b892f60)
@@ -350,7 +350,7 @@ suite('Search API', function() {
     var domain;
 
     setup(function() {
-      domain = new Domain('people', context)
+      domain = new Domain({ name: 'people', context: context })
                  .setId('00000000000000000000000000').saveSync();
       domain.getIndexField('realname').setType('text')
         .setResultEnabled(true).saveSync();

  Modified: test/bq-translator.test.js (+1 -1)
===================================================================
--- test/bq-translator.test.js    2012-12-06 18:23:16 +0900 (a0230ec)
+++ test/bq-translator.test.js    2012-12-06 19:23:41 +0900 (3a59f48)
@@ -166,7 +166,7 @@ suite('BoolanQueryTranslator', function() {
   setup(function() {
     temporaryDatabase = utils.createTemporaryDatabase();
     context = temporaryDatabase.get();
-    domain = new Domain('test', context).createSync();
+    domain = new Domain({ name: 'test', context: context }).createSync();
     [
       'type',
       'name',

  Modified: test/database-domain.test.js (+27 -27)
===================================================================
--- test/database-domain.test.js    2012-12-06 18:23:16 +0900 (bf6ec24)
+++ test/database-domain.test.js    2012-12-06 19:23:41 +0900 (0e0a1e6)
@@ -120,7 +120,7 @@ suite('database', function() {
       test('not supported', function() {
         assert.throw(function() {
           var request = { query: { DomainName: 'test0123' } };
-          var domain = new Domain(request).validate();
+          var domain = new Domain({ source: request }).validate();
         }, /no domain name/);
       });
     });
@@ -187,7 +187,7 @@ suite('database', function() {
       test('from host, valid', function() {
         var host = 'doc-test0123-id0123.example.com';
         var request = { headers: { host: host } };
-        var domain = new Domain(request).validate();
+        var domain = new Domain({ source: request }).validate();
         assert.deepEqual({ name: domain.name, id: domain.id },
                          { name: 'test0123', id: 'id0123' });
       });
@@ -196,7 +196,7 @@ suite('database', function() {
         assert.throw(function() {
           var host = 'doc-domain_name-id0123.example.com';
           var request = { headers: { host: host } };
-          var domain = new Domain(request).validate();
+          var domain = new Domain({ source: request }).validate();
         }, '1 validation error detected: ' +
              'Value \'domain_name\' at \'%NAME_FIELD%\' failed to satisfy constraint: ' +
                'Member must satisfy regular expression pattern: ' +
@@ -207,7 +207,7 @@ suite('database', function() {
         var host = 'example.com';
         var request = { headers: { host: host },
                         url: '/gcs/test0123-id0123' };
-        var domain = new Domain(request).validate();
+        var domain = new Domain({ source: request }).validate();
         assert.deepEqual({ name: domain.name, id: domain.id },
                          { name: 'test0123', id: 'id0123' });
       });
@@ -217,7 +217,7 @@ suite('database', function() {
           var host = 'example.com';
         var request = { headers: { host: host },
                         url: '/gcs/test_0123-id0123' };
-          var domain = new Domain(request).validate();
+          var domain = new Domain({ source: request }).validate();
         }, '1 validation error detected: ' +
              'Value \'domain_name\' at \'%NAME_FIELD%\' failed to satisfy constraint: ' +
                'Member must satisfy regular expression pattern: ' +
@@ -228,7 +228,7 @@ suite('database', function() {
         var host = 'doc-test0123-id0123.example.com';
         var request = { headers: { host: host },
                         url: '/gcs/test4567-id4567' };
-        var domain = new Domain(request).validate();
+        var domain = new Domain({ source: request }).validate();
         assert.deepEqual({ name: domain.name, id: domain.id },
                          { name: 'test0123', id: 'id0123' });
       });
@@ -238,7 +238,7 @@ suite('database', function() {
         var request = { headers: { host: host },
                         url: '/gcs/test4567-id4567',
                         query: { DomainName: 'test890' } };
-        var domain = new Domain(request).validate();
+        var domain = new Domain({ source: request }).validate();
         assert.equal(domain.name, 'test0123');
       });
     });
@@ -276,7 +276,7 @@ suite('database', function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
         utils.loadDumpFile(context, __dirname + '/fixture/companies/ddl-custom-id.grn');
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
       });
 
       teardown(function() {
@@ -291,7 +291,7 @@ suite('database', function() {
       });
 
       test('id for database (unknown, new table)', function() {
-        domain = new Domain('unknown', context);
+        domain = new Domain({ name: 'unknown', context: context });
         assert.equal(typeof domain.id, 'string');
         assert.deepEqual({ idLength:     domain.id.length,
                            normalizedId: domain.id.replace(/[1-9a-z]/g, '0'),
@@ -419,7 +419,7 @@ suite('database', function() {
         domain.defaultSearchField = nameField;
         assert.equal(domain.defaultSearchField, nameField);
 
-        var anotherDomainInstance = new Domain('companies', context);
+        var anotherDomainInstance = new Domain({ name: 'companies', context: context });
         assert.equal(anotherDomainInstance.defaultSearchField,
                      anotherDomainInstance.getIndexField('name'));
       });
@@ -430,7 +430,7 @@ suite('database', function() {
         domain.defaultSearchField = 'name';
         assert.equal(domain.defaultSearchField, domain.getIndexField('name'));
 
-        var anotherDomainInstance = new Domain('companies', context);
+        var anotherDomainInstance = new Domain({ name: 'companies', context: context });
         assert.equal(anotherDomainInstance.defaultSearchField,
                      anotherDomainInstance.getIndexField('name'));
       });
@@ -452,7 +452,7 @@ suite('database', function() {
         assert.isTrue(domain.defaultSearchField === null,
                       domain.defaultSearchField);
 
-        var anotherDomainInstance = new Domain('companies', context);
+        var anotherDomainInstance = new Domain({ name: 'companies', context: context });
         assert.equal(anotherDomainInstance.defaultSearchField, null);
       });
     });
@@ -472,7 +472,7 @@ suite('database', function() {
       });
 
       test('createSync', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         assert.isFalse(domain.exists());
 
         domain.createSync();
@@ -494,7 +494,7 @@ suite('database', function() {
       });
 
       test('createSync again', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.createSync();
         assert.throw(function() {
           domain.createSync();
@@ -502,7 +502,7 @@ suite('database', function() {
       });
 
       test('deleteSync', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
         assert.isTrue(domain.exists());
 
@@ -515,7 +515,7 @@ suite('database', function() {
       });
 
       test('deleteSync again', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
         domain.deleteSync();
         assert.throw(function() {
@@ -524,7 +524,7 @@ suite('database', function() {
       });
 
       test('updateSynonymsSync, initialize', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         assert.isFalse(domain.hasSynonymsTableSync());
 
         domain.updateSynonymsSync({
@@ -560,7 +560,7 @@ suite('database', function() {
       });
 
       test('updateSynonymsSync, replace', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.updateSynonymsSync({
           tokio: ['tokyo'],
           dekkaido: 'hokkaido'
@@ -595,7 +595,7 @@ suite('database', function() {
       });
 
       test('getSynonymSync, existent', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.updateSynonymsSync({
           tokio: ['tonkin', 'tokyo']
         });
@@ -604,7 +604,7 @@ suite('database', function() {
       });
 
       test('getSynonymSync, nonexistent', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.updateSynonymsSync({
           tokio: ['tonkin', 'tokyo']
         });
@@ -613,7 +613,7 @@ suite('database', function() {
       });
 
       test('getSynonymsSync', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         domain.updateSynonymsSync({
           tokio: ['tonkin', 'tokyo'],
           dekkaido: 'hokkaido'
@@ -628,20 +628,20 @@ suite('database', function() {
       });
 
       test('getSynonymsSync for new domain', function() {
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         var expectedSynonyms = {};
         var synonyms = domain.getSynonymsSync();
         assert.deepEqual(synonyms, expectedSynonyms);
       });
 
       test('getAll', function() {
-        var domain3 = new Domain('domain3', context);
+        var domain3 = new Domain({ name: 'domain3', context: context });
         domain3.saveSync();
 
-        var domain1 = new Domain('domain1', context);
+        var domain1 = new Domain({ name: 'domain1', context: context });
         domain1.saveSync();
 
-        var domain2 = new Domain('domain2', context);
+        var domain2 = new Domain({ name: 'domain2', context: context });
         domain2.saveSync();
 
         var allDomains = Domain.getAll(context);
@@ -665,7 +665,7 @@ suite('database', function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
         utils.loadDumpFile(context, __dirname + '/fixture/companies/ddl.grn');
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
       });
 
       teardown(function() {
@@ -799,7 +799,7 @@ suite('database', function() {
       setup(function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
       });
 

  Modified: test/database-index-field.test.js (+7 -7)
===================================================================
--- test/database-index-field.test.js    2012-12-06 18:23:16 +0900 (08cd7e7)
+++ test/database-index-field.test.js    2012-12-06 19:23:41 +0900 (7ade06e)
@@ -14,7 +14,7 @@ suite('database', function() {
     setup(function() {
       temporaryDatabase = utils.createTemporaryDatabase();
       context = temporaryDatabase.get();
-      domain = new Domain('testdomain', context);
+      domain = new Domain({ name: 'testdomain', context: context });
       domain.id = Domain.DEFAULT_ID;
       domain.saveSync();
     });
@@ -209,7 +209,7 @@ suite('database', function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
         utils.loadDumpFile(context, __dirname + '/fixture/companies/ddl.grn');
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
       });
 
       teardown(function() {
@@ -252,7 +252,7 @@ suite('database', function() {
       setup(function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
       });
 
@@ -398,7 +398,7 @@ suite('database', function() {
       setup(function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
         field = domain.getIndexField('field').setType('text');
       });
@@ -538,7 +538,7 @@ suite('database', function() {
       setup(function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
       });
 
@@ -714,7 +714,7 @@ suite('database', function() {
       setup(function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
       });
 
@@ -782,7 +782,7 @@ suite('database', function() {
       setup(function() {
         temporaryDatabase = utils.createTemporaryDatabase();
         context = temporaryDatabase.get();
-        domain = new Domain('companies', context);
+        domain = new Domain({ name: 'companies', context: context });
         domain.saveSync();
       });
 

  Modified: test/gcs-commands.test.js (+28 -28)
===================================================================
--- test/gcs-commands.test.js    2012-12-06 18:23:16 +0900 (85e6468)
+++ test/gcs-commands.test.js    2012-12-06 19:23:41 +0900 (9519bb2)
@@ -54,7 +54,7 @@ suite('gcs-create-domain', function() {
                        'Domain endpoints are currently being created.');
 
         context.reopen();
-        var domain = new Domain('test', context);
+        var domain = new Domain({ name: 'test', context: context });
         assert.isTrue(domain.exists());
 
         done();
@@ -65,7 +65,7 @@ suite('gcs-create-domain', function() {
   });
 
   test('create again', function(done) {
-    new Domain('test', context).createSync();
+    new Domain({ name: 'test', context: context }).createSync();
     utils
       .run('gcs-create-domain',
            '--domain-name', 'test',
@@ -113,7 +113,7 @@ suite('gcs-delete-domain', function() {
   teardown(commonTeardown);
 
   test('delete force', function(done) {
-    new Domain('test', context).createSync();
+    new Domain({ name: 'test', context: context }).createSync();
     utils
       .run('gcs-delete-domain',
            '--domain-name', 'test',
@@ -127,7 +127,7 @@ suite('gcs-delete-domain', function() {
                          result.output.stderr);
 
         context.reopen();
-        var domain = new Domain('test', context);
+        var domain = new Domain({ name: 'test', context: context });
         assert.isFalse(domain.exists());
 
         done();
@@ -182,8 +182,8 @@ suite('gcs-describe-domain', function() {
   var hostPort = '127.0.0.1.xip.io:' + utils.testPort;
 
   test('describe one', function(done) {
-    var domain2 = new Domain('domain2', context).createSync();
-    var domain1 = new Domain('domain1', context).createSync();
+    var domain2 = new Domain({ name: 'domain2', context: context }).createSync();
+    var domain1 = new Domain({ name: 'domain1', context: context }).createSync();
     var nameField = domain1.getIndexField('name').setType('text').createSync();
     var ageField = domain1.getIndexField('age').setType('uint').createSync();
     utils
@@ -191,7 +191,7 @@ suite('gcs-describe-domain', function() {
            '--domain-name', 'domain1',
            '--endpoint', 'localhost:' + utils.testPort)
       .next(function(result) {
-        var domain = new Domain('domain1', context);
+        var domain = new Domain({ name: 'domain1', context: context });
         assert.deepEqual({ code: result.code, message: result.output.stdout },
                          { code: 0,
                            message:
@@ -224,15 +224,15 @@ suite('gcs-describe-domain', function() {
   });
 
   test('describe all', function(done) {
-    new Domain('domain2', context).createSync();
-    new Domain('domain1', context).createSync();
+    new Domain({ name: 'domain1', context: context }).createSync();
+    new Domain({ name: 'domain2', context: context }).createSync();
     utils
       .run('gcs-describe-domain',
            '--show-all',
            '--endpoint', 'localhost:' + utils.testPort)
       .next(function(result) {
-        var domain1 = new Domain('domain1', context);
-        var domain2 = new Domain('domain2', context);
+        var domain1 = new Domain({ name: 'domain1', context: context });
+        var domain2 = new Domain({ name: 'domain2', context: context });
         assert.deepEqual({ code: result.code, message: result.output.stdout },
                          { code: 0,
                            message:
@@ -298,7 +298,7 @@ suite('gcs-configure-fields', function() {
   }
 
   function testCreateField(done, name, type, options) {
-    new Domain('companies', context).createSync();
+    new Domain({ name: 'companies', context: context }).createSync();
     utils
       .run('gcs-create-domain',
            '--domain-name', 'companies',
@@ -312,7 +312,7 @@ suite('gcs-configure-fields', function() {
         assertSuccess(result, name, 'RequiresIndexDocuments', type, options);
 
         context.reopen();
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         var field = domain.getIndexField(name);
         assert.deepEqual({ type: field.type, exists: field.exists() },
                          { type: type, exists: true });
@@ -335,7 +335,7 @@ suite('gcs-configure-fields', function() {
   });
 
   function testDeleteField(done, name, type) {
-    var domain = new Domain('companies', context);
+    var domain = new Domain({ name: 'companies', context: context });
     domain.createSync();
     var field = domain.getIndexField(name).setType(type);
     field.createSync();
@@ -354,7 +354,7 @@ suite('gcs-configure-fields', function() {
                          result.output.stderr);
 
         context.reopen();
-        var domain = new Domain('companies', context);
+        var domain = new Domain({ name: 'companies', context: context });
         var field = domain.getIndexField(name);
         assert.isFalse(field.exists());
 
@@ -376,7 +376,7 @@ suite('gcs-configure-fields', function() {
   });
 
   test('delete not-existing field', function(done) {
-    new Domain('companies', context).createSync();
+    new Domain({ name: 'companies', context: context }).createSync();
     utils
       .run('gcs-configure-fields',
            '--domain-name', 'companies',
@@ -398,7 +398,7 @@ suite('gcs-configure-fields', function() {
   });
 
   test('create field without type', function(done) {
-    new Domain('companies', context).createSync();
+    new Domain({ name: 'companies', context: context }).createSync();
     utils
       .run('gcs-configure-fields',
            '--domain-name', 'companies',
@@ -448,7 +448,7 @@ suite('gcs-configure-fields', function() {
 
   function testConfigureFieldOptionSuccess(type, options, resultOptions) {
     test('with options ' + type + ', ' + options, function(done) {
-      new Domain('companies', context).createSync();
+      new Domain({ name: 'companies', context: context }).createSync();
       utils
         .run.apply(utils, createCommandLineArgs(type, options))
         .next(function(result) {
@@ -467,7 +467,7 @@ suite('gcs-configure-fields', function() {
 
   function testConfigureFieldOptionFailure(type, options) {
     test('with options ' + type + ', ' + options, function(done) {
-      new Domain('companies', context).createSync();
+      new Domain({ name: 'companies', context: context }).createSync();
       utils
         .run.apply(utils, createCommandLineArgs(type, options))
         .next(function(result) {
@@ -546,7 +546,7 @@ suite('gcs-configure-text-options', function() {
   teardown(commonTeardown);
 
   test('load synonyms', function() {
-    new Domain('companies', context).createSync();
+    new Domain({ name: 'companies', context: context }).createSync();
     utils
       .run('gcs-configure-text-options',
            '--domain-name', 'companies',
@@ -595,7 +595,7 @@ suite('gcs-configure-text-options', function() {
   });
 
   test('print synonyms', function() {
-    var domain = new Domain('companies', context);
+    var domain = new Domain({ name: 'companies', context: context });
     domain.createSync();
     domain.updateSynonymsSync({
       hokkaido: 'dekkaido',
@@ -655,7 +655,7 @@ suite('gcs-configure-default-search-field', function() {
   teardown(commonTeardown);
 
   test('set to an existing field', function(done) {
-    var domain = new Domain('companies', context).createSync();
+    var domain = new Domain({ name: 'companies', context: context }).createSync();
     domain.getIndexField('name').setType('text').createSync();
     utils
       .run('gcs-configure-default-search-field',
@@ -679,7 +679,7 @@ suite('gcs-configure-default-search-field', function() {
   });
 
   test('set to a missing field', function(done) {
-    var domain = new Domain('companies', context).createSync();
+    var domain = new Domain({ name: 'companies', context: context }).createSync();
     domain.getIndexField('name').setType('text').createSync();
     utils
       .run('gcs-configure-default-search-field',
@@ -705,7 +705,7 @@ suite('gcs-configure-default-search-field', function() {
   });
 
   test('set to blank', function(done) {
-    var domain = new Domain('companies', context).createSync();
+    var domain = new Domain({ name: 'companies', context: context }).createSync();
     domain.getIndexField('name').setType('text').createSync();
     utils
       .run('gcs-configure-default-search-field',
@@ -734,7 +734,7 @@ suite('gcs-configure-default-search-field', function() {
   });
 
   test('set to blank (omitted "name" option)', function(done) {
-    var domain = new Domain('companies', context).createSync();
+    var domain = new Domain({ name: 'companies', context: context }).createSync();
     domain.getIndexField('name').setType('text').createSync();
     utils
       .run('gcs-configure-default-search-field',
@@ -762,7 +762,7 @@ suite('gcs-configure-default-search-field', function() {
   });
 
   test('Described default search field', function(done) {
-    var domain = new Domain('companies', context).createSync();
+    var domain = new Domain({ name: 'companies', context: context }).createSync();
     domain.getIndexField('name').setType('text').createSync();
     utils
       .run('gcs-configure-default-search-field',
@@ -789,7 +789,7 @@ suite('gcs-index-documents', function() {
   teardown(commonTeardown);
 
   test('reindex', function(done) {
-    var domain = new Domain('companies', context);
+    var domain = new Domain({ name: 'companies', context: context });
     domain.createSync();
     domain.getIndexField('name').setType('text').createSync();
     domain.getIndexField('age').setType('uint').createSync();
@@ -857,7 +857,7 @@ suite('gcs-post-sdf', function() {
 
   var endpoint;
   function setupDomain() {
-    var domain = new Domain('companies', context);
+    var domain = new Domain({ name: 'companies', context: context });
     domain.createSync();
     domain.getIndexField('name').setType('text').createSync();
     domain.getIndexField('address').setType('text').createSync();
-------------- next part --------------
HTML����������������������������...
Télécharger 



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