Skip to content

Commit

Permalink
Handle Not Implemented error code in functional test in s3 Gateway mo…
Browse files Browse the repository at this point in the history
…de (minio#639)

tests that call listenBucketNotification handles "Not Implemented"
error code.

Fixes minio#636
  • Loading branch information
kannappanr authored and Krishna Srinivas committed Oct 6, 2017
1 parent 2c627ba commit fb712f4
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/test/functional/functional-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,27 +978,38 @@ describe('functional tests', function() {
step('listenBucketNotification(bucketName, prefix, suffix, events)_events:bad_', done => {
let poller = client.listenBucketNotification(bucketName, 'photos/', '.jpg', ['bad'])
poller.on('error', error => {
assert.match(error.message, /A specified event is not supported for notifications./)
assert.equal(error.code, 'InvalidArgument')

if (error.code != 'NotImplemented') {
assert.match(error.message, /A specified event is not supported for notifications./)
assert.equal(error.code, 'InvalidArgument')
}
done()
})
})
step('listenBucketNotification(bucketName, prefix, suffix, events)_events: ObjectCreated_', done => {
let poller = client.listenBucketNotification(bucketName, '', '', ['s3:ObjectCreated:*'])
let records = 0
let notImplemented = false
poller.on('notification', record => {
records++

assert.equal(record.eventName, 's3:ObjectCreated:Put')
assert.equal(record.s3.bucket.name, bucketName)
assert.equal(record.s3.object.key, objectName)
})
poller.on('error', error => {
if (error.code != 'NotImplemented') {
done(error)
} else {
notImplemented = true
}
})
client.putObject(bucketName, objectName, 'stringdata', (err) => {
if (err) return done(err)
// It polls every five seconds, so wait for two-ish polls, then end.
setTimeout(() => {
assert.equal(records, 1)
if (notImplemented == false) {
assert.equal(records, 1)
}
poller.stop()
client.removeObject(bucketName, objectName, done)
}, 11 * 1000)
Expand Down

0 comments on commit fb712f4

Please sign in to comment.