diff --git a/test/listShards.js b/test/listShards.js index e4475b5..4da2eaf 100644 --- a/test/listShards.js +++ b/test/listShards.js @@ -6,7 +6,8 @@ var target = 'ListShards', opts = helpers.opts.bind(null, target), assertType = helpers.assertType.bind(null, target), assertValidation = helpers.assertValidation.bind(null, target), - assertNotFound = helpers.assertNotFound.bind(null, target) + assertNotFound = helpers.assertNotFound.bind(null, target), + assertInvalidArgument = helpers.assertInvalidArgument.bind(null, target) describe('listShards', function() { @@ -24,19 +25,24 @@ describe('listShards', function() { assertType('ExclusiveStartShardId', 'String', done) }) + it('should return SerializationException when NextToken is not a String', function(done) { + assertType('NextToken', 'String', done) + }) + + it('should return SerializationException when StreamCreationTimestamp is not a Timestamp', function(done) { + assertType('StreamCreationTimestamp', 'Timestamp', done) + }) + }) describe('validations', function() { - it('should return ValidationException for no StreamName', function(done) { - assertValidation({}, [ - 'Value null at \'streamName\' failed to satisfy constraint: ' + - 'Member must not be null', - ], done) + it('should return InvalidArgumentException for no StreamName or NextToken', function(done) { + assertInvalidArgument({}, 'Either NextToken or StreamName should be provided.', done) }) it('should return ValidationException for empty StreamName', function(done) { - assertValidation({StreamName: '', MaxResults: 0, ExclusiveStartShardId: ''}, [ + assertValidation({StreamName: '', NextToken: '', MaxResults: 0, ExclusiveStartShardId: ''}, [ 'Value \'0\' at \'maxResults\' failed to satisfy constraint: ' + 'Member must have value greater than or equal to 1', 'Value \'\' at \'exclusiveStartShardId\' failed to satisfy constraint: ' + @@ -47,6 +53,8 @@ describe('listShards', function() { 'Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+', 'Value \'\' at \'streamName\' failed to satisfy constraint: ' + 'Member must have length greater than or equal to 1', + 'Value \'\' at \'nextToken\' failed to satisfy constraint: ' + + 'Member must have length greater than or equal to 1', ], done) }) @@ -62,6 +70,12 @@ describe('listShards', function() { ], done) }) + it('should return InvalidArgumentException if both StreamName and NextToken', function(done) { + var name = randomName() + assertInvalidArgument({StreamName: name, NextToken: name}, + 'NextToken and StreamName cannot be provided together.', done) + }) + it('should return ResourceNotFoundException if stream does not exist', function(done) { var name = randomName() assertNotFound({StreamName: name}, 'Stream ' + name + ' under account ' + @@ -72,7 +86,7 @@ describe('listShards', function() { describe('functionality', function() { - it('should return stream description', function(done) { + it('should return stream shards', function(done) { request(opts({StreamName: helpers.testStream}), function(err, res) { if (err) return done(err) res.statusCode.should.equal(200)