[Groonga-commit] groonga/gcs [master] Add more tests for gcs-update-text-options

Zurück zum Archiv-Index

null+****@clear***** null+****@clear*****
2012年 8月 9日 (木) 16:49:03 JST


SHIMODA Hiroshi	2012-08-09 16:49:03 +0900 (Thu, 09 Aug 2012)

  New Revision: 3b38ed3a49a9b1be0594c055ac652f92cf5fa683
  https://github.com/groonga/gcs/commit/3b38ed3a49a9b1be0594c055ac652f92cf5fa683

  Log:
    Add more tests for gcs-update-text-options

  Modified files:
    test/gcs-commands.test.js

  Modified: test/gcs-commands.test.js (+80 -30)
===================================================================
--- test/gcs-commands.test.js    2012-08-09 16:41:46 +0900 (403f30b)
+++ test/gcs-commands.test.js    2012-08-09 16:49:03 +0900 (8bfa66d)
@@ -19,6 +19,22 @@ function commonTeardown() {
   temporaryDatabase = undefined;
 }
 
+function assertDomainNotSpecified(result) {
+  assert.deepEqual({ code:    result.code,
+                     message: result.output.stdout },
+                   { code:    1,
+                     message: 'You must specify the domain name.\n' },
+                   result.output.stderr);
+}
+
+function assertDomainNotExist(result) {
+  assert.deepEqual({ code:    result.code,
+                     message: result.output.stdout },
+                   { code:    1,
+                     message: 'You must specify an existing domain name.\n' },
+                   result.output.stderr);
+}
+
 suite('gcs-create-domain', function() {
   setup(commonSetup);
   teardown(commonTeardown);
@@ -75,11 +91,7 @@ suite('gcs-create-domain', function() {
       .run('gcs-create-domain',
            '--database-path', temporaryDatabase.path)
       .next(function(result) {
-        assert.deepEqual({ code:    result.code,
-                           message: result.output.stdout },
-                         { code:    1,
-                           message: 'You must specify the domain name.\n' },
-                         result.output.stderr);
+        assertDomainNotSpecified(result);
 
         context.reopen();
         assert.deepEqual(Domain.getAll(context), []);
@@ -128,11 +140,7 @@ suite('gcs-delete-domain', function() {
            '--force',
            '--database-path', temporaryDatabase.path)
       .next(function(result) {
-        assert.deepEqual({ code:    result.code,
-                           message: result.output.stdout },
-                         { code:    1,
-                           message: 'You must specify an existing domain name.\n' },
-                         result.output.stderr);
+        assertDomainNotExist(result);
         done();
       })
       .error(function(e) {
@@ -146,11 +154,7 @@ suite('gcs-delete-domain', function() {
            '--force',
            '--database-path', temporaryDatabase.path)
       .next(function(result) {
-        assert.deepEqual({ code:    result.code,
-                           message: result.output.stdout },
-                         { code:    1,
-                           message: 'You must specify the domain name.\n' },
-                         result.output.stderr);
+        assertDomainNotSpecified(result);
         done();
       })
       .error(function(e) {
@@ -386,11 +390,7 @@ suite('gcs-configure-fields', function() {
            '--name', 'name',
            '--database-path', temporaryDatabase.path)
       .next(function(result) {
-        assert.deepEqual({ code:    result.code,
-                           message: result.output.stdout },
-                         { code:    1,
-                           message: 'You must specify the domain name.\n' },
-                         result.output.stderr);
+        assertDomainNotSpecified(result);
         done();
       })
       .error(function(e) {
@@ -423,6 +423,35 @@ suite('gcs-configure-text-options', function() {
       });
   });
 
+  test('load synonyms to not-existing domain', function() {
+    utils
+      .run('gcs-configure-text-options',
+           '--domain-name', 'companies',
+           '--synonyms', path.join(__dirname, 'fixtures', 'synonyms.txt'),
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assertDomainNotExist(result);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
+  test('load synonyms without domain', function() {
+    utils
+      .run('gcs-configure-text-options',
+           '--synonyms', path.join(__dirname, 'fixtures', 'synonyms.txt'),
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assertDomainNotSpecified(result);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
   test('print synonyms', function() {
     var domain = new Domain('companies', context);
     domain.createSync();
@@ -448,6 +477,35 @@ suite('gcs-configure-text-options', function() {
         done(e);
       });
   });
+
+  test('print synonyms to not-existing domain', function() {
+    utils
+      .run('gcs-configure-text-options',
+           '--domain-name', 'companies',
+           '--print-synonyms',
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assertDomainNotExist(result);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
+  test('print synonyms without domain', function() {
+    utils
+      .run('gcs-configure-text-options',
+           '--print-synonyms',
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assertDomainNotSpecified(result);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
 });
 
 suite('gcs-index-documents', function() {
@@ -498,11 +556,7 @@ suite('gcs-index-documents', function() {
            '--domain-name', 'test',
            '--database-path', temporaryDatabase.path)
       .next(function(result) {
-        assert.deepEqual({ code:    result.code,
-                           message: result.output.stdout },
-                         { code:    1,
-                           message: 'You must specify an existing domain name.\n' },
-                         result.output.stderr);
+        assertDomainNotExist(result);
         done();
       })
       .error(function(e) {
@@ -515,11 +569,7 @@ suite('gcs-index-documents', function() {
       .run('gcs-index-documents',
            '--database-path', temporaryDatabase.path)
       .next(function(result) {
-        assert.deepEqual({ code:    result.code,
-                           message: result.output.stdout },
-                         { code:    1,
-                           message: 'You must specify the domain name.\n' },
-                         result.output.stderr);
+        assertDomainNotSpecified(result);
         done();
       })
       .error(function(e) {
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Zurück zum Archiv-Index