Skip to content

Commit 6addb74

Browse files
bigtable: upgrade dependencies & clean system tests
1 parent a744f26 commit 6addb74

2 files changed

Lines changed: 37 additions & 40 deletions

File tree

packages/bigtable/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
"dependencies": {
5353
"arrify": "^1.0.0",
5454
"concat-stream": "^1.5.0",
55-
"create-error-class": "^2.0.1",
56-
"dot-prop": "^2.4.0",
55+
"create-error-class": "^3.0.2",
56+
"dot-prop": "^4.0.0",
5757
"extend": "^3.0.0",
58-
"@google-cloud/common": "^0.3.0",
58+
"@google-cloud/common": "^0.4.0",
5959
"google-proto-files": "^0.7.0",
6060
"is": "^3.0.1",
6161
"lodash.flatten": "^4.2.0",

packages/bigtable/system-test/bigtable.js

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,25 @@ var Table = require('../src/table.js');
2828
var Family = require('../src/family.js');
2929
var Row = require('../src/row.js');
3030

31-
function generateName(obj) {
32-
return ['test', obj, uuid.v4()].join('-');
33-
}
31+
var PREFIX = 'gcloud-tests-';
3432

3533
describe('Bigtable', function() {
36-
var bigtable;
34+
var bigtable = new Bigtable(env);
3735

38-
var INSTANCE_NAME = 'test-bigtable-instance';
39-
var INSTANCE;
40-
41-
var TABLE_NAME = generateName('table');
42-
var TABLE;
43-
44-
var CLUSTER_NAME = 'test-bigtable-cluster';
36+
var INSTANCE = bigtable.instance(generateName('instance'));
37+
var TABLE = INSTANCE.table(generateName('table'));
38+
var CLUSTER_NAME = generateName('cluster');
4539

4640
before(function(done) {
47-
bigtable = new Bigtable(env);
48-
49-
INSTANCE = bigtable.instance(INSTANCE_NAME);
50-
51-
var options = {
52-
clusters: [{
53-
name: CLUSTER_NAME,
54-
location: 'us-central1-b',
55-
nodes: 3
56-
}]
57-
};
58-
59-
INSTANCE.create(options, function(err, instance, operation) {
41+
INSTANCE.create({
42+
clusters: [
43+
{
44+
name: CLUSTER_NAME,
45+
location: 'us-central1-b',
46+
nodes: 3
47+
}
48+
]
49+
}, function(err, instance, operation) {
6050
if (err) {
6151
done(err);
6252
return;
@@ -65,8 +55,6 @@ describe('Bigtable', function() {
6555
operation
6656
.on('error', done)
6757
.on('complete', function() {
68-
TABLE = INSTANCE.table(TABLE_NAME);
69-
7058
TABLE.create({
7159
families: ['follows', 'traits']
7260
}, done);
@@ -75,7 +63,20 @@ describe('Bigtable', function() {
7563
});
7664

7765
after(function(done) {
78-
INSTANCE.delete(done);
66+
bigtable.getInstances(function(err, instances) {
67+
if (err) {
68+
done(err);
69+
return;
70+
}
71+
72+
var testInstances = instances.filter(function(instance) {
73+
return instance.id.indexOf(PREFIX) === 0;
74+
});
75+
76+
async.eachLimit(testInstances, 5, function(instance, next) {
77+
instance.delete(next);
78+
}, done);
79+
});
7980
});
8081

8182
describe('instances', function() {
@@ -121,9 +122,7 @@ describe('Bigtable', function() {
121122
});
122123

123124
it('should get a single instance', function(done) {
124-
var instance = bigtable.instance(INSTANCE_NAME);
125-
126-
instance.get(done);
125+
INSTANCE.get(done);
127126
});
128127

129128
it('should update an instance', function(done) {
@@ -261,13 +260,7 @@ describe('Bigtable', function() {
261260
});
262261

263262
it('should get a table', function(done) {
264-
var table = INSTANCE.table(TABLE_NAME);
265-
266-
table.get(function(err, table_) {
267-
assert.ifError(err);
268-
assert.strictEqual(table, table_);
269-
done();
270-
});
263+
TABLE.get(done);
271264
});
272265

273266
it('should delete a table', function(done) {
@@ -931,3 +924,7 @@ describe('Bigtable', function() {
931924
});
932925

933926
});
927+
928+
function generateName(resourceType) {
929+
return PREFIX + resourceType + '-' + uuid.v1().substr(0, 8);
930+
}

0 commit comments

Comments
 (0)