Skip to content

Commit

Permalink
Merge pull request #283 from stephenplusplus/spp--bq-reg-rm-storage-b…
Browse files Browse the repository at this point in the history
…uckets

bq: tests: clean up what is created. fixes #282
  • Loading branch information
silvolu committed Nov 6, 2014
2 parents 204b3e1 + 14bbc94 commit 7d78904
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions regression/bigquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

/*global describe, it, before */
/*global describe, it, before, after */

'use strict';

Expand All @@ -31,10 +31,11 @@ var bigquery = gcloud.bigquery();
var storage = gcloud.storage();

describe('BigQuery', function() {
var DATASET_ID = 'testDatasetId';
var DATASET_ID = ('gcloud_test_dataset_temp' + uuid.v1()).replace(/-/g, '_');
var dataset;
var TABLE_ID = 'myKittens';
var table;
var BUCKET_NAME = 'gcloud-test-bucket-temp-' + uuid.v1();
var bucket;

var query = 'SELECT url FROM [publicdata:samples.github_nested] LIMIT 100';
Expand Down Expand Up @@ -86,8 +87,7 @@ describe('BigQuery', function() {

// Create a Bucket.
function(next) {
var bucketName = 'gcloud-test-bucket-temp-' + uuid.v1();
storage.createBucket(bucketName, function(err, b) {
storage.createBucket(BUCKET_NAME, function(err, b) {
if (err) {
next(err);
return;
Expand All @@ -100,6 +100,36 @@ describe('BigQuery', function() {
], done);
});

after(function(done) {
async.parallel([
// Delete the bucket we used.
function(next) {
bucket.getFiles(function(err, files) {
if (err) {
next(err);
return;
}

async.map(files, function(file, onComplete) {
file.delete(onComplete);
}, function(err) {
if (err) {
next(err);
return;
}

bucket.delete(next);
});
});
},

// Delete the test dataset.
function(next) {
dataset.delete({ force: true }, next);
}
], done);
});

it('should get a list of datasets', function(done) {
bigquery.getDatasets(function(err, datasets) {
assert(datasets.length > 0);
Expand Down

0 comments on commit 7d78904

Please sign in to comment.