diff --git a/packages/google-cloud-dns/samples/package.json b/packages/google-cloud-dns/samples/package.json index 4162b5bbbe2..ab1c527722d 100644 --- a/packages/google-cloud-dns/samples/package.json +++ b/packages/google-cloud-dns/samples/package.json @@ -5,8 +5,7 @@ "license": "Apache Version 2.0", "author": "Google Inc.", "scripts": { - "test": "cd ..; npm run t -- dns/test/*.test.js", - "system-test": "cd ..; npm run st -- dns/system-test/*.test.js" + "test": "cd ..; npm run st -- dns/system-test/*.test.js" }, "dependencies": { "@google-cloud/dns": "0.4.0", diff --git a/packages/google-cloud-dns/samples/quickstart.js b/packages/google-cloud-dns/samples/quickstart.js index fd657ba3fc7..f686c389ddc 100644 --- a/packages/google-cloud-dns/samples/quickstart.js +++ b/packages/google-cloud-dns/samples/quickstart.js @@ -28,13 +28,11 @@ const dnsClient = DNS({ }); // Lists all zones in the current project -dnsClient.getZones((err, zones) => { - if (err) { - console.error(err); - return; - } +dnsClient.getZones() + .then((results) => { + const zones = results[0]; - console.log('Zones:'); - zones.forEach((zone) => console.log(zone.name)); -}); + console.log('Zones:'); + zones.forEach((zone) => console.log(zone.name)); + }); // [END dns_quickstart] diff --git a/packages/google-cloud-dns/samples/test/quickstart.test.js b/packages/google-cloud-dns/samples/test/quickstart.test.js deleted file mode 100644 index cbceb9ecb2d..00000000000 --- a/packages/google-cloud-dns/samples/test/quickstart.test.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2016, Google, Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const proxyquire = require(`proxyquire`).noCallThru(); - -describe(`dns:quickstart`, () => { - let dnsMock, DNSMock; - const error = new Error(`error`); - - before(() => { - dnsMock = { - getZones: sinon.stub().yields(error) - }; - DNSMock = sinon.stub().returns(dnsMock); - }); - - it(`should handle error`, () => { - proxyquire(`../quickstart`, { - '@google-cloud/dns': DNSMock - }); - - assert.equal(DNSMock.calledOnce, true); - assert.deepEqual(DNSMock.firstCall.args, [{ projectId: 'YOUR_PROJECT_ID' }]); - assert.equal(dnsMock.getZones.calledOnce, true); - assert.deepEqual(dnsMock.getZones.firstCall.args.slice(0, -1), []); - assert.equal(console.error.calledOnce, true); - assert.deepEqual(console.error.firstCall.args, [error]); - }); -});