YUKI Hiroshi
null+****@clear*****
Thu Oct 18 16:41:03 JST 2012
YUKI Hiroshi 2012-10-18 16:41:03 +0900 (Thu, 18 Oct 2012) New Revision: 93a01445fa768b013ccf82afa268e7297cc95d92 https://github.com/groonga/gcs/commit/93a01445fa768b013ccf82afa268e7297cc95d92 Log: Fix tests around DescribeIndexFields Modified files: test/api-configuration.test.js test/xml-responses.js Modified: test/api-configuration.test.js (+18 -8) =================================================================== --- test/api-configuration.test.js 2012-10-18 16:19:10 +0900 (8cbf8e4) +++ test/api-configuration.test.js 2012-10-18 16:41:03 +0900 (d611e44) @@ -631,12 +631,12 @@ suite('Configuration API', function() { .DescribeIndexFieldsResult .IndexFields .member; - var domains = []; + var fields = []; for (var i in members) { if (members.hasOwnProperty(i)) - domains.push(members[i].DomainName); + fields.push(members[i].Options.IndexFieldName); } - return domains; + return fields; } test('all', function(done) { @@ -646,9 +646,14 @@ suite('Configuration API', function() { 'Action=DescribeIndexFields&Version=2011-02-01') .next(function(response) { var expectedFields = ['age', 'name', 'product']; + response = xmlResponses.toParsedResponse(response); assert.deepEqual(response.pattern, { statusCode: 200, - body: xmlResponses.DescribeIndexFieldsResponse(expectedFields) }); + body: xmlResponses.DescribeIndexFieldsResponse([ + xmlResponses.IndexFieldStatus_UInt, + xmlResponses.IndexFieldStatus_Text, + xmlResponses.IndexFieldStatus_Literal + ]) }); var actualFields = getActualDescribedFields(response); assert.deepEqual(actualFields, expectedFields); @@ -663,13 +668,17 @@ suite('Configuration API', function() { test('specified', function(done) { var domain, field; utils - .get('/?DomainName=companies&FieldNames.member.1=name&' + + .get('/?DomainName=companies&FieldNames.member.1=name&FieldNames.member.2=age&' + 'Action=DescribeIndexFields&Version=2011-02-01') .next(function(response) { - var expectedFields = ['name']; + var expectedFields = ['name', 'age']; + response = xmlResponses.toParsedResponse(response); assert.deepEqual(response.pattern, { statusCode: 200, - body: xmlResponses.DescribeIndexFieldsResponse(expectedFields) }); + body: xmlResponses.DescribeIndexFieldsResponse([ + xmlResponses.IndexFieldStatus_Text, + xmlResponses.IndexFieldStatus_UInt + ]) }); var actualFields = getActualDescribedFields(response); assert.deepEqual(actualFields, expectedFields); @@ -688,9 +697,10 @@ suite('Configuration API', function() { 'Action=DescribeIndexFields&Version=2011-02-01') .next(function(response) { var expectedFields = []; + response = xmlResponses.toParsedResponse(response); assert.deepEqual(response.pattern, { statusCode: 200, - body: xmlResponses.DescribeIndexFieldsResponse(expectedFields) }); + body: xmlResponses.DescribeIndexFieldsResponse([]) }); var actualFields = getActualDescribedFields(response); assert.deepEqual(actualFields, expectedFields); Modified: test/xml-responses.js (+3 -3) =================================================================== --- test/xml-responses.js 2012-10-18 16:19:10 +0900 (c2ee7c6) +++ test/xml-responses.js 2012-10-18 16:41:03 +0900 (ac0522e) @@ -56,7 +56,7 @@ exports.DescribeDomainsResponse = function(members) { members.forEach(function(member, index) { pattern[index] = DomainStatus; }); - return { member: pattern }; + return members.length ? { member: pattern } : {} ; })() }); }; @@ -80,7 +80,7 @@ var IndexField_Text = IndexFieldType: '', TextOptions: TextOptions }; -var IndexFieldStatus_Text = +var sus_Text = exports.IndexFieldStatus_Text = { Options: IndexField_Text, Status: OptionStatus @@ -139,7 +139,7 @@ exports.DescribeIndexFieldsResponse = function(members) { members.forEach(function(member, index) { pattern[index] = member; }); - return { member: pattern }; + return members.length ? { member: pattern } : {} ; })() }); }; -------------- next part -------------- HTML����������������������������...Download