From 093d07a7883119f9548b55701a576165e3015016 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 17 Dec 2018 12:12:48 -0800 Subject: [PATCH] test: add sample tests (#143) --- container/snippets/package.json | 9 +++++-- container/snippets/quickstart.js | 1 + container/snippets/system-test/.eslintrc.yml | 6 ++--- container/snippets/system-test/sample.test.js | 26 +++++++++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 container/snippets/system-test/sample.test.js diff --git a/container/snippets/package.json b/container/snippets/package.json index fd53c9f95f..9a7b5ed8d7 100644 --- a/container/snippets/package.json +++ b/container/snippets/package.json @@ -7,13 +7,18 @@ }, "repository": "googleapis/nodejs-cloud-container", "private": true, + "files": [ + "*.js" + ], "scripts": { - "test": "echo no sample tests 👻" + "test": "mocha system-test --timeout 10000" }, "dependencies": { "@google-cloud/container": "^0.3.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.0.0" + "chai": "^4.2.0", + "execa": "^1.0.0", + "mocha": "^5.2.0" } } diff --git a/container/snippets/quickstart.js b/container/snippets/quickstart.js index 1cb292b7f6..36e995f4a2 100644 --- a/container/snippets/quickstart.js +++ b/container/snippets/quickstart.js @@ -39,6 +39,7 @@ async function main() { }; const [response] = await client.listClusters(request); + console.log('Clusters:'); console.log(response); // [END container_quickstart] } diff --git a/container/snippets/system-test/.eslintrc.yml b/container/snippets/system-test/.eslintrc.yml index c0289282a6..6db2a46c53 100644 --- a/container/snippets/system-test/.eslintrc.yml +++ b/container/snippets/system-test/.eslintrc.yml @@ -1,5 +1,3 @@ --- -rules: - node/no-unpublished-require: off - node/no-unsupported-features: off - no-empty: off +env: + mocha: true diff --git a/container/snippets/system-test/sample.test.js b/container/snippets/system-test/sample.test.js new file mode 100644 index 0000000000..7cd82c0d9c --- /dev/null +++ b/container/snippets/system-test/sample.test.js @@ -0,0 +1,26 @@ +/** + * Copyright 2017, 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 {assert} = require('chai'); +const execa = require('execa'); + +describe('container samples', () => { + it('should run the quickstart', async () => { + const {stdout} = await execa.shell('node quickstart'); + assert.match(stdout, /Clusters:/); + }); +});