{"size": 3007, "ext": "js", "max_stars_repo_path": "test/describeStreamSummary.js", "max_stars_repo_name": "Hulios/kinesalite", "max_stars_repo_stars_event_min_datetime": "2015-01-19T10:13:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T00:23:03.000Z", "max_issues_repo_path": "test/describeStreamSummary.js", "max_issues_repo_name": "Hulios/kinesalite", "max_issues_repo_issues_event_min_datetime": "2015-01-28T04:14:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-13T20:13:20.000Z", "max_forks_repo_path": "test/describeStreamSummary.js", "max_forks_repo_name": "Hulios/kinesalite", "max_forks_repo_forks_event_min_datetime": "2015-01-10T00:43:17.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-02T02:13:14.000Z"}
{"max_stars_count": 798, "max_issues_count": 97, "max_forks_count": 104, "avg_line_length": 34.1704545455, "max_line_length": 100, "alphanum_fraction": 0.6361822414}
var helpers = require('./helpers')

var target = 'DescribeStreamSummary',
    request = helpers.request,
    randomName = helpers.randomName,
    opts = helpers.opts.bind(null, target),
    assertType = helpers.assertType.bind(null, target),
    assertValidation = helpers.assertValidation.bind(null, target),
    assertNotFound = helpers.assertNotFound.bind(null, target)

describe('describeStreamSummary', function() {

  describe('serializations', function() {

    it('should return SerializationException when StreamName is not a String', function(done) {
      assertType('StreamName', 'String', 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 ValidationException for empty StreamName', function(done) {
      assertValidation({StreamName: ''}, [
        'Value \'\' at \'streamName\' failed to satisfy constraint: ' +
        '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',
      ], done)
    })

    it('should return ValidationException for long StreamName', function(done) {
      var name = new Array(129 + 1).join('a')
      assertValidation({StreamName: name}, [
        'Value \'' + name + '\' at \'streamName\' failed to satisfy constraint: ' +
        'Member must have length less than or equal to 128',
      ], done)
    })

    it('should return ResourceNotFoundException if stream does not exist', function(done) {
      var name = randomName()
      assertNotFound({StreamName: name}, 'Stream ' + name + ' under account ' +
        helpers.awsAccountId + ' not found.', done)
    })

  })

  describe('functionality', function() {

    it('should return stream description summary', function(done) {
      request(opts({StreamName: helpers.testStream}), function(err, res) {
        if (err) return done(err)
        res.statusCode.should.equal(200)

        res.body.StreamDescriptionSummary.StreamCreationTimestamp.should.be.above(0)
        res.body.StreamDescriptionSummary.StreamCreationTimestamp.should.be.below(Date.now() / 1000)
        delete res.body.StreamDescriptionSummary.StreamCreationTimestamp

        res.body.should.eql({
          StreamDescriptionSummary: {
            StreamStatus: 'ACTIVE',
            StreamName: helpers.testStream,
            StreamARN: 'arn:aws:kinesis:' + helpers.awsRegion + ':' + helpers.awsAccountId +
              ':stream/' + helpers.testStream,
            RetentionPeriodHours: 24,
            EncryptionType: 'NONE',
            EnhancedMonitoring: [{ShardLevelMetrics: []}],
            OpenShardCount: 3,
            ConsumerCount: 0,
          },
        })

        done()
      })
    })

  })

})

