[Groonga-commit] groonga/gcs [master] Add test for Domain.getAll() (and sort the result)

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 3日 (金) 14:59:58 JST


SHIMODA Hiroshi	2012-08-03 14:59:58 +0900 (Fri, 03 Aug 2012)

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

  Log:
    Add test for Domain.getAll() (and sort the result)

  Modified files:
    lib/database/domain.js
    test/database-domain.test.js

  Modified: lib/database/domain.js (+1 -0)
===================================================================
--- lib/database/domain.js    2012-08-03 14:51:51 +0900 (669092f)
+++ lib/database/domain.js    2012-08-03 14:59:58 +0900 (6bd6e4d)
@@ -336,5 +336,6 @@ Domain.getAll = function(context) {
       domains.push(new Domain(name, context));
     }
   });
+  domains.sort(function(a, b) { return a.name - b.name; });
   return domains;
 };

  Modified: test/database-domain.test.js (+21 -0)
===================================================================
--- test/database-domain.test.js    2012-08-03 14:51:51 +0900 (8afe0c0)
+++ test/database-domain.test.js    2012-08-03 14:59:58 +0900 (855f4b4)
@@ -231,6 +231,27 @@ suite('database', function() {
                            exists:       false });
       });
 
+      test('getAll', function() {
+        var domain3 = new Domain('domain3', context);
+        domain3.createSync();
+
+        var domain1 = new Domain('domain1', context);
+        domain1.createSync();
+
+        var domain2 = new Domain('domain2', context);
+        domain2.createSync();
+
+        var allDomains = Domain.getAll(context);
+        assert.deepEqual(allDomains.map(function(domain) {
+                           return domain.tableName;
+                         }),
+                         [
+                           domain1.tableName,
+                           domain2.tableName,
+                           domain3.tableName
+                         ]);
+      });
+
       test('indexFields', function() {
         var fields = domain.indexFields;
         fields = fields.map(function(field) {
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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