Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bq: tests: clean up what is created. fixes #282 #283

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bq: tests: clean up what is created. fixes #282
  • Loading branch information
stephenplusplus committed Nov 6, 2014
commit 14bbc94be34a856232a0c5d11b588b523620d2eb
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