[Groonga-commit] groonga/gcs [master] Add tests for errors

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 9日 (木) 19:18:56 JST


SHIMODA Hiroshi	2012-08-09 19:18:56 +0900 (Thu, 09 Aug 2012)

  New Revision: cfce7d23862103e9d11b97f90135955f55476149
  https://github.com/groonga/gcs/commit/cfce7d23862103e9d11b97f90135955f55476149

  Log:
    Add tests for errors

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

  Modified: test/gcs-commands.test.js (+66 -3)
===================================================================
--- test/gcs-commands.test.js    2012-08-09 19:13:12 +0900 (d020ad6)
+++ test/gcs-commands.test.js    2012-08-09 19:18:56 +0900 (20c0037)
@@ -633,7 +633,7 @@ suite('gcs-post-sdf', function() {
     domain.getIndexField('product').setType('literal').createSync();
   }
 
-  test('post add sdf', function(done) {
+  test('post add sdf json', function(done) {
     setupDomain();
     var batchFile = path.join(fixturesDirectory, 'add.sdf.json');
     utils
@@ -660,7 +660,7 @@ suite('gcs-post-sdf', function() {
       });
   });
 
-  test('post delete sdf', function(done) {
+  test('post delete sdf json', function(done) {
     setupDomain();
     var batchFile = path.join(fixturesDirectory, 'delete.sdf.json');
     utils
@@ -691,7 +691,7 @@ suite('gcs-post-sdf', function() {
       });
   });
 
-  test('post invalid sdf', function(done) {
+  test('post invalid sdf json', function(done) {
     setupDomain();
     var batchFile = path.join(fixturesDirectory, 'invalid.sdf.json');
     utils
@@ -726,6 +726,69 @@ suite('gcs-post-sdf', function() {
       });
   });
 
+  test('post no source', function(done) {
+    setupDomain();
+    utils
+      .run('gcs-post-sdf',
+           '--domain-name', 'companies',
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assert.deepEqual({ code:    result.code,
+                           message: result.output.stdout },
+                         { code:    1,
+                           message: 'You must specify the source SDF.\n' },
+                         result.output.stderr);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
+  test('post unknown format file', function(done) {
+    setupDomain();
+    var batchFile = path.join(__dirname, 'fixtures', 'synonyms.txt');
+    utils
+      .run('gcs-post-sdf',
+           '--domain-name', 'companies',
+           '--source', batchFile,
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assert.deepEqual({ code:    result.code,
+                           message: result.output.stdout },
+                         { code:    1,
+                           message: 'Processing: ' + batchFile + '\n' +
+                                    'Unknown format\n' },
+                         result.output.stderr);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
+  test('post missing file', function(done) {
+    setupDomain();
+    var batchFile = path.join(__dirname, 'fixtures', 'not-exists.json');
+    utils
+      .run('gcs-post-sdf',
+           '--domain-name', 'companies',
+           '--source', batchFile,
+           '--database-path', temporaryDatabase.path)
+      .next(function(result) {
+        assert.deepEqual({ code:    result.code,
+                           message: result.output.stdout },
+                         { code:    1,
+                           message: 'Processing: ' + batchFile + '\n' +
+                                    'No such file\n' },
+                         result.output.stderr);
+        done();
+      })
+      .error(function(e) {
+        done(e);
+      });
+  });
+
   test('post not-existing domain', function(done) {
     utils
       .run('gcs-post-sdf',
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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