[Groonga-commit] groonga/gcs [master] Update test for the correct behavior of the CreateDomain action

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Nov 5 13:36:03 JST 2012


YUKI Hiroshi	2012-11-05 13:36:03 +0900 (Mon, 05 Nov 2012)

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

  Log:
    Update test for the correct behavior of the CreateDomain action

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

  Modified: test/api-configuration.test.js (+30 -27)
===================================================================
--- test/api-configuration.test.js    2012-11-05 13:31:33 +0900 (e98e754)
+++ test/api-configuration.test.js    2012-11-05 13:36:03 +0900 (29a1ee0)
@@ -24,6 +24,34 @@ suite('Configuration API', function() {
 
   var defaultBaseHost = 'localhost:' + utils.testPort;
 
+  function assertDomainCreatedResponse(response, domainName) {
+    var domain = new Domain(domainName, context);
+    assert.isTrue(domain.exists());
+
+    response = xmlResponses.toParsedResponse(response);
+    assert.deepEqual(response.pattern,
+                     { statusCode: 200,
+                       body: xmlResponses.CreateDomainResponse });
+    var expectedStatus = {
+          Created: 'true',
+          Deleted: 'false',
+          DocService: {
+            Endpoint: domain.getDocumentsEndpoint(defaultBaseHost)
+          },
+          DomainId: domain.domainId,
+          DomainName: domain.name,
+          NumSearchableDocs: String(domain.searchableDocumentsCount),
+          RequiresIndexDocuments: String(domain.requiresIndexDocuments),
+          SearchInstanceCount: String(domain.searchInstanceCount),
+          SearchPartitionCount: String(domain.searchPartitionCount),
+          SearchService: {
+            Endpoint: domain.getSearchEndpoint(defaultBaseHost)
+          }
+        };
+    var status = response.body.CreateDomainResponse.CreateDomainResult.DomainStatus;
+    assert.deepEqual(status, expectedStatus);
+  }
+
   suite('domain operations', function() {
     setup(commonSetup);
     teardown(commonTeardown);
@@ -32,32 +60,7 @@ suite('Configuration API', function() {
       utils
         .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
         .next(function(response) {
-          var domain = new Domain('companies', context);
-          assert.isTrue(domain.exists());
-
-          response = xmlResponses.toParsedResponse(response);
-          assert.deepEqual(response.pattern,
-                           { statusCode: 200,
-                             body: xmlResponses.CreateDomainResponse });
-          var expectedStatus = {
-                Created: 'true',
-                Deleted: 'false',
-                DocService: {
-                  Endpoint: domain.getDocumentsEndpoint(defaultBaseHost)
-                },
-                DomainId: domain.domainId,
-                DomainName: domain.name,
-                NumSearchableDocs: String(domain.searchableDocumentsCount),
-                RequiresIndexDocuments: String(domain.requiresIndexDocuments),
-                SearchInstanceCount: String(domain.searchInstanceCount),
-                SearchPartitionCount: String(domain.searchPartitionCount),
-                SearchService: {
-                  Endpoint: domain.getSearchEndpoint(defaultBaseHost)
-                }
-              };
-          var status = response.body.CreateDomainResponse.CreateDomainResult.DomainStatus;
-          assert.deepEqual(status, expectedStatus);
-
+          assertDomainCreatedResponse(response, 'companies');
           done();
         })
         .error(function(error) {
@@ -70,7 +73,7 @@ suite('Configuration API', function() {
         .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
         .get('/?DomainName=companies&Action=CreateDomain&Version=2011-02-01')
         .next(function(response) {
-          assert.notEqual(response.statusCode, 200);
+          assertDomainCreatedResponse(response, 'companies');
           done();
         }).error(function(error) {
           done(error)
-------------- next part --------------
HTML����������������������������...
下载 



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