[Groonga-commit] groonga/gcs [master] Refactor test for DefineIndexField action (uint, literal)

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 13日 (金) 19:04:07 JST


SHIMODA Hiroshi	2012-07-13 19:04:07 +0900 (Fri, 13 Jul 2012)

  New Revision: 255af0a169e9a85e19c269d5e7cab91ebf116926
  https://github.com/groonga/gcs/commit/255af0a169e9a85e19c269d5e7cab91ebf116926

  Log:
    Refactor test for DefineIndexField action (uint, literal)

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

  Modified: test/api-configuration.test.js (+27 -63)
===================================================================
--- test/api-configuration.test.js    2012-07-13 19:01:41 +0900 (afe2261)
+++ test/api-configuration.test.js    2012-07-13 19:04:07 +0900 (2e78a17)
@@ -342,37 +342,19 @@ suite('Configuration API', function() {
                          'COLUMN_INDEX|WITH_POSITION companies age';
         assert.equal(dump, expected);
 
-        var expected = {
-              statusCode: 200,
-              body: '<?xml version="1.0"?>\n' +
-                    '<DefineIndexFieldResponse xmlns="' + XMLNS + '">' +
-                      '<DefineIndexFieldResult>' +
-                        '<IndexField>' +
-                          '<Options>' +
-                            '<IndexFieldName>age</IndexFieldName>' +
-                            '<IndexFieldType>uint</IndexFieldType>' +
-                            '<UIntOptions>' +
-                              '<DefaultValue/>' +
-                            '</UIntOptions>' +
-                          '</Options>' +
-                          '<Status>' +
-                            '<CreationDate>1970-01-01T00:00:00Z</CreationDate>' +
-                            '<State>RequiresIndexDocuments</State>' +
-                            '<UpdateDate>1970-01-01T00:00:00Z</UpdateDate>' +
-                            '<UpdateVersion>0</UpdateVersion>' +
-                          '</Status>' +
-                        '</IndexField>' +
-                      '</DefineIndexFieldResult>' +
-                      '<ResponseMetadata>' +
-                        '<RequestId></RequestId>' +
-                      '</ResponseMetadata>' +
-                    '</DefineIndexFieldResponse>'
-            };
-        var actual = {
-              statusCode: response.statusCode,
-              body: replaceXMLDates(response.body)
+        response = toParsedResponse(response);
+        assert.deepEqual(response.pattern,
+                         { statusCode: 200,
+                           body: PATTERN_DefineIndexFieldResponse_UInt });
+        var expectedOptions = {
+              IndexFieldName: 'age',
+              IndexFieldType: 'uint',
+              UIntOptions: {
+                DefaultValue: {}
+              }
             };
-        assert.deepEqual(actual, expected);
+        var options = response.body.DefineIndexFieldResponse.DefineIndexFieldResult.IndexField.Options;
+        assert.deepEqual(options, expectedOptions);
 
         done();
       })
@@ -407,40 +389,22 @@ suite('Configuration API', function() {
                        'column_create companies member COLUMN_SCALAR companies_member';
         assert.equal(dump, expected);
 
-        var expected = {
-              statusCode: 200,
-              body: '<?xml version="1.0"?>\n' +
-                    '<DefineIndexFieldResponse xmlns="' + XMLNS + '">' +
-                      '<DefineIndexFieldResult>' +
-                        '<IndexField>' +
-                          '<Options>' +
-                            '<IndexFieldName>member</IndexFieldName>' +
-                            '<IndexFieldType>literal</IndexFieldType>' +
-                            '<LiteralOptions>' +
-                              '<DefaultValue/>' +
-                              '<FacetEnabled>false</FacetEnabled>' +
-                              '<ResultEnabled>false</ResultEnabled>' +
-                              '<SearchEnabled>false</SearchEnabled>' +
-                            '</LiteralOptions>' +
-                          '</Options>' +
-                          '<Status>' +
-                            '<CreationDate>1970-01-01T00:00:00Z</CreationDate>' +
-                            '<State>RequiresIndexDocuments</State>' +
-                            '<UpdateDate>1970-01-01T00:00:00Z</UpdateDate>' +
-                            '<UpdateVersion>0</UpdateVersion>' +
-                          '</Status>' +
-                        '</IndexField>' +
-                      '</DefineIndexFieldResult>' +
-                      '<ResponseMetadata>' +
-                        '<RequestId></RequestId>' +
-                      '</ResponseMetadata>' +
-                    '</DefineIndexFieldResponse>'
-            };
-        var actual = {
-              statusCode: response.statusCode,
-              body: replaceXMLDates(response.body)
+        response = toParsedResponse(response);
+        assert.deepEqual(response.pattern,
+                         { statusCode: 200,
+                           body: PATTERN_DefineIndexFieldResponse_Literal });
+        var expectedOptions = {
+              IndexFieldName: 'member',
+              IndexFieldType: 'literal',
+              UIntOptions: {
+                DefaultValue: {},
+                FacetEnabled: 'false',
+                ResultEnabled: 'false',
+                SearchEnabled: 'false'
+              }
             };
-        assert.deepEqual(actual, expected);
+        var options = response.body.DefineIndexFieldResponse.DefineIndexFieldResult.IndexField.Options;
+        assert.deepEqual(options, expectedOptions);
 
         done();
       })
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



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