[Groonga-commit] groonga/gcs [master] Move tests of database modifications to the test for Domain

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 2日 (木) 13:24:35 JST


SHIMODA Hiroshi	2012-08-02 13:24:35 +0900 (Thu, 02 Aug 2012)

  New Revision: 07a538c44d79d4f5d5424e840ab5732aecc12eb4
  https://github.com/groonga/gcs/commit/07a538c44d79d4f5d5424e840ab5732aecc12eb4

  Log:
    Move tests of database modifications to the test for Domain

  Modified files:
    test/api-configuration.test.js
    test/database-domain.test.js

  Modified: test/api-configuration.test.js (+2 -11)
===================================================================
--- test/api-configuration.test.js    2012-08-02 13:13:52 +0900 (0c8ad16)
+++ test/api-configuration.test.js    2012-08-02 13:24:35 +0900 (ba94b38)
@@ -233,14 +233,7 @@ suite('Configuration API', function() {
          'Host': 'cloudsearch.localhost'
        })
       .next(function(response) {
-        var dump = context.commandSync('dump', {
-              tables: 'companies'
-            });
-        var expectedDump = 'table_create companies_00000000000000000000000000 TABLE_HASH_KEY ShortText\n' +
-                           'table_create companies_00000000000000000000000000_BigramTerms ' +
-                             'TABLE_PAT_KEY|KEY_NORMALIZE ShortText ' +
-                             '--default_tokenizer TokenBigram';
-        assert.equal(dump, expectedDump);
+        assert.isTrue((new Domain('companies', context).exists()));
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,
@@ -281,9 +274,7 @@ suite('Configuration API', function() {
         'Host': 'cloudsearch.localhost'
       })
       .next(function(response) {
-        var dump = context.commandSync('dump');
-        var expectedDump = '';
-        assert.equal(dump, expectedDump);
+        assert.isFalse((new Domain('companies', context).exists()));
 
         response = toParsedResponse(response);
         assert.deepEqual(response.pattern,

  Modified: test/database-domain.test.js (+47 -0)
===================================================================
--- test/database-domain.test.js    2012-08-02 13:13:52 +0900 (89f7472)
+++ test/database-domain.test.js    2012-08-02 13:24:35 +0900 (fcfb7fa)
@@ -259,5 +259,52 @@ suite('database', function() {
         assert.deepEqual(fields.sort(sortFields), expected.sort(sortFields));
       });
     });
+
+    suite('database modifications', function() {
+      var temporaryDatabase;
+      var context;
+
+      setup(function() {
+        temporaryDatabase = utils.createTemporaryDatabase();
+        context = temporaryDatabase.get();
+      });
+
+      teardown(function() {
+        temporaryDatabase.teardown();
+        temporaryDatabase = undefined;
+      });
+
+      test('createSync', function() {
+        var domain = new Domain('companies', context);
+        domain.id = Domain.DEFAULT_ID;
+        assert.isFalse(domain.exists());
+
+        domain.createSync();
+        assert.isTrue(domain.exists());
+
+        var dump = context.commandSync('dump', {
+              tables: domain.tableName
+            });
+        var expectedDump = 'table_create ' + domain.tableName + ' TABLE_HASH_KEY ShortText\n' +
+                           'table_create ' + domain.termsTableName + ' ' +
+                             'TABLE_PAT_KEY|KEY_NORMALIZE ShortText ' +
+                             '--default_tokenizer TokenBigram';
+        assert.equal(dump, expectedDump);
+      });
+
+      test('deleteSync', function() {
+        var domain = new Domain('companies', context);
+        domain.id = Domain.DEFAULT_ID;
+        domain.createSync();
+        assert.isTrue(domain.exists());
+
+        domain.deleteSync();
+        assert.isFalse(domain.exists());
+
+        var dump = context.commandSync('dump');
+        var expectedDump = '';
+        assert.equal(dump, expectedDump);
+      });
+    });
   });
 });
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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