Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Commit

Permalink
Update listShards tests to include InvalidArgumentExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mhart committed Apr 4, 2018
1 parent 3b97966 commit 6aafef2
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions test/listShards.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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: ' +
Expand All @@ -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)
})

Expand All @@ -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 ' +
Expand All @@ -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)
Expand Down

0 comments on commit 6aafef2

Please sign in to comment.