diff --git a/lib/storage/index.js b/lib/storage/index.js index 1959a28d7ad..819fa24c5b6 100644 --- a/lib/storage/index.js +++ b/lib/storage/index.js @@ -146,6 +146,9 @@ ReadStream.prototype.pipe = function(dest, opts) { * create a bucket. */ function Bucket(opts) { + if (!opts.bucketName) { + throw Error('A bucket name is needed to use Google Cloud Storage'); + } this.bucketName = opts.bucketName; this.conn = new conn.Connection({ keyFilename: opts.keyFilename, diff --git a/test/storage.js b/test/storage.js index bb0da080718..8115237403e 100644 --- a/test/storage.js +++ b/test/storage.js @@ -29,6 +29,10 @@ function createBucket() { describe('Bucket', function() { + it('should throw if a bucket name is not passed', function() { + assert.throws(function() { var bucket = new storage.Bucket(); }, Error); + }) + it('should list without a query', function(done) { var bucket = createBucket(); bucket.makeReq = function(method, path, q, body, callback) {