Skip to content

Commit

Permalink
callback removed from promise-style code-snippets within region-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay-qlogic committed Aug 7, 2018
1 parent 726a1c2 commit cce0496
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"prettier": "prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js",
"publish-module": "node ../../scripts/publish.js bigtable",
"system-test": "mocha system-test/*.js --timeout 600000",
"snippet-test": "mocha samples/document-snippets/test.js --timeout 600000"
"snippet-test": "mocha samples/document-snippets/tests/*.js --timeout 600000"
},
"dependencies": {
"@google-cloud/common-grpc": "^0.7.1",
Expand Down
1 change: 1 addition & 0 deletions samples/document-snippets/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ env:
mocha: true
rules:
node/no-unpublished-require: off
no-unused-vars: off
24 changes: 12 additions & 12 deletions samples/document-snippets/family.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ const snippets = {
.then(result => {
const family = result[0];
// let apiResponse = result[1];
callback(null, family);
})
.catch(err => {
callback(err);
// handle error
});
// [END bigtable_create_family]
callback();
},
existsFamily: (instanceId, tableId, familyId, callback) => {
const instance = bigtable.instance(instanceId);
Expand All @@ -44,12 +44,12 @@ const snippets = {
.exists()
.then(result => {
const exists = result[0];
callback(null, exists);
})
.catch(err => {
callback(err);
// handle error
});
// [END bigtable_exists_family]
callback();
},
getFamily: (instanceId, tableId, familyId, callback) => {
const instance = bigtable.instance(instanceId);
Expand All @@ -61,12 +61,12 @@ const snippets = {
.then(result => {
const family = result[0];
// const apiResponse = result[1];
callback(null, family);
})
.catch(err => {
callback(err);
// handle error
});
// [END bigtable_get_family]
callback();
},
getMetaData: (instanceId, tableId, familyId, callback) => {
const instance = bigtable.instance(instanceId);
Expand All @@ -78,12 +78,12 @@ const snippets = {
.then(result => {
const metaData = result[0];
// const apiResponse = result[1];
callback(null, metaData);
})
.catch(err => {
callback(err);
// handle error
});
// [END bigtable_get_family_meta]
callback();
},
setMetaData: (instanceId, tableId, familyId, callback) => {
const instance = bigtable.instance(instanceId);
Expand All @@ -100,12 +100,12 @@ const snippets = {
.setMetadata(metadata)
.then(result => {
const apiResponse = result[0];
callback(null, apiResponse);
})
.catch(err => {
callback(err);
// handle error
});
// [END bigtable_set_family_meta]
callback();
},
delFamily: (instanceId, tableId, familyId, callback) => {
const instance = bigtable.instance(instanceId);
Expand All @@ -116,12 +116,12 @@ const snippets = {
.delete()
.then(result => {
const apiResponse = result[0];
callback(null, apiResponse);
})
.catch(err => {
callback(err);
// handle error
});
// [END bigtable_del_family]
callback();
},
};

Expand Down
32 changes: 7 additions & 25 deletions samples/document-snippets/tests/family.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const familySnippets = require('../family.js');

const instance = bigtable.instance(INSTANCE_ID);

describe('Family Snippets', function() {
describe.only('Family Snippets', function() {
before(async () => {
await instance.create({
clusters: [
Expand All @@ -50,44 +50,26 @@ describe('Family Snippets', function() {
});

it('should create a column family', function(done) {
familySnippets.createColmFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, err => {
assert.ifError(err);
done();
});
familySnippets.createColmFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, done);
});

it('should check family exists', function(done) {
familySnippets.existsFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, err => {
assert.ifError(err);
done();
});
familySnippets.existsFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, done);
});

it('should get the family', function(done) {
familySnippets.getFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, err => {
assert.ifError(err);
done();
});
familySnippets.getFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, done);
});

it('should get family meta-data', function(done) {
familySnippets.getMetaData(INSTANCE_ID, TABLE_ID, FAMILY_ID, err => {
assert.ifError(err);
done();
});
familySnippets.getMetaData(INSTANCE_ID, TABLE_ID, FAMILY_ID, done);
});

it('should set family meta-data', function(done) {
familySnippets.setMetaData(INSTANCE_ID, TABLE_ID, FAMILY_ID, err => {
assert.ifError(err);
done();
});
familySnippets.setMetaData(INSTANCE_ID, TABLE_ID, FAMILY_ID, done);
});

it('should delete family', function(done) {
familySnippets.delFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, err => {
assert.ifError(err);
done();
});
familySnippets.delFamily(INSTANCE_ID, TABLE_ID, FAMILY_ID, done);
});
});

0 comments on commit cce0496

Please sign in to comment.