[Groonga-commit] groonga/gcs [master] Fix minor bugs around gcs-configure-fields

Back to archive index

SHIMODA Hiroshi null+****@clear*****
Mon Aug 13 18:58:12 JST 2012


SHIMODA Hiroshi	2012-08-13 18:58:12 +0900 (Mon, 13 Aug 2012)

  New Revision: 5b23b6e0efecda7d5aee66eac58a760604d02c01
  https://github.com/groonga/gcs/commit/5b23b6e0efecda7d5aee66eac58a760604d02c01

  Log:
    Fix minor bugs around gcs-configure-fields

  Modified files:
    bin/gcs-configure-fields
    lib/database/index-field.js
    test/gcs-commands.test.js

  Modified: bin/gcs-configure-fields (+8 -4)
===================================================================
--- bin/gcs-configure-fields    2012-08-13 18:49:09 +0900 (5c44f12)
+++ bin/gcs-configure-fields    2012-08-13 18:58:12 +0900 (8921326)
@@ -37,6 +37,10 @@ if (!commandLine.options.name) {
 
 var field = commandLine.domain.getIndexField(commandLine.options.name);
 
+var option = commandLine.options.option;
+if (typeof option != 'string')
+  option = null;
+
 if (commandLine.options.delete) {
   if (!field.exists()) {
     console.log('You must specify an existing field.');
@@ -51,14 +55,14 @@ if (commandLine.options.delete) {
       return process.exit(1);
     }
     field.type = commandLine.options.type;
-  } else if (!commandLine.options.option) {
+  } else if (!option) {
     console.log('You must specify the configuring option.');
     return process.exit(1);
   }
 
-  if (commandLine.options.option) {
+  if (option) {
     try {
-      switch (commandLine.options.option) {
+      switch (option) {
         case 'search':   field.searchEnabled = true;  break;
         case 'nosearch': field.searchEnabled = false; break;
         case 'facet':    field.facetEnabled =  true;  break;
@@ -66,7 +70,7 @@ if (commandLine.options.delete) {
         case 'result':   field.resultEnabled = true;  break;
         case 'noresult': field.resultEnabled = false; break;
         default:
-          throw new Error('invalid field option ' + commandLine.options.option);
+          throw new Error('invalid field option ' + option);
       }
     } catch(error) {
       console.log((error.message || error).toString());

  Modified: lib/database/index-field.js (+3 -3)
===================================================================
--- lib/database/index-field.js    2012-08-13 18:49:09 +0900 (e75ccdf)
+++ lib/database/index-field.js    2012-08-13 18:58:12 +0900 (d9dbe95)
@@ -156,7 +156,7 @@ IndexField.prototype = {
   },
   set facetEnabled(value) {
     if (this.type == 'uint')
-      throw new Error('facet option cannot be configured for the type ' + this.type);
+      throw new Error('facet option cannot be configured for the type ' + this.type + '.');
 
     this._facetEnabled = value;
     return value;
@@ -181,7 +181,7 @@ IndexField.prototype = {
   },
   set resultEnabled(value) {
     if (this.type == 'uint')
-      throw new Error('returnable option cannot be configured for the type ' + this.type);
+      throw new Error('returnable option cannot be configured for the type ' + this.type + '.');
 
     this._resultEnabled = value;
     return value;
@@ -206,7 +206,7 @@ IndexField.prototype = {
   },
   set searchEnabled(value) {
     if (this.type == 'text' || this.type == 'uint')
-      throw new Error('searchable option cannot be configured for the type ' + this.type);
+      throw new Error('searchable option cannot be configured for the type ' + this.type + '.');
 
     this._searchEnabled = value;
     return value;

  Modified: test/gcs-commands.test.js (+7 -1)
===================================================================
--- test/gcs-commands.test.js    2012-08-13 18:49:09 +0900 (99a0124)
+++ test/gcs-commands.test.js    2012-08-13 18:58:12 +0900 (241a50c)
@@ -369,7 +369,7 @@ suite('gcs-configure-fields', function() {
         assert.deepEqual({ code:    result.code,
                            message: result.output.stdout },
                          { code:    1,
-                           message: 'You must specify not-existing field name.\n' },
+                           message: 'You must specify the configuring option.\n' },
                          result.output.stderr);
         done();
       })
@@ -471,6 +471,7 @@ suite('gcs-configure-fields', function() {
     domain.getIndexField(name).setType(type).createSync();
     utils
       .run('gcs-configure-fields',
+           '--domain-name', 'companies',
            '--name', name,
            '--option', 'search',
            '--database-path', temporaryDatabase.path)
@@ -481,6 +482,7 @@ suite('gcs-configure-fields', function() {
           assertOptionConfigured(result, name, type, results.search);
       })
       .run('gcs-configure-fields',
+           '--domain-name', 'companies',
            '--name', name,
            '--option', 'nosearch',
            '--database-path', temporaryDatabase.path)
@@ -491,6 +493,7 @@ suite('gcs-configure-fields', function() {
           assertOptionConfigured(result, name, type, results.nosearch);
       })
       .run('gcs-configure-fields',
+           '--domain-name', 'companies',
            '--name', name,
            '--option', 'result',
            '--database-path', temporaryDatabase.path)
@@ -501,6 +504,7 @@ suite('gcs-configure-fields', function() {
           assertOptionConfigured(result, name, type, results.result);
       })
       .run('gcs-configure-fields',
+           '--domain-name', 'companies',
            '--name', name,
            '--option', 'noresult',
            '--database-path', temporaryDatabase.path)
@@ -511,6 +515,7 @@ suite('gcs-configure-fields', function() {
           assertOptionConfigured(result, name, type, results.noresult);
       })
       .run('gcs-configure-fields',
+           '--domain-name', 'companies',
            '--name', name,
            '--option', 'facet',
            '--database-path', temporaryDatabase.path)
@@ -521,6 +526,7 @@ suite('gcs-configure-fields', function() {
           assertOptionConfigured(result, name, type, results.facet);
       })
       .run('gcs-configure-fields',
+           '--domain-name', 'companies',
            '--name', name,
            '--option', 'nofacet',
            '--database-path', temporaryDatabase.path)
-------------- next part --------------
HTML����������������������������...
Download 



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