From 2d5928fbf83ab2d5881451c6be1f8406f3fb76d2 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Mon, 24 Apr 2017 14:40:11 -0700 Subject: [PATCH] Cleanup App Engine samples and re-work tests. (#354) --- .../samples/README.md | 34 +++++++++++++++---- .../samples/package.json | 29 ++++++++++++---- .../samples/quickstart.js | 5 ++- 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/packages/google-cloud-resourcemanager/samples/README.md b/packages/google-cloud-resourcemanager/samples/README.md index 9a75a28b284..d45896e1b4c 100644 --- a/packages/google-cloud-resourcemanager/samples/README.md +++ b/packages/google-cloud-resourcemanager/samples/README.md @@ -16,14 +16,21 @@ programmatically manage these container resources. * [Setup](#setup) * [Samples](#samples) * [Projects](#projects) +* [Running the tests](#running-the-tests) ## Setup -1. Read [Prerequisites][prereq] and [How to run a sample][run] first. -1. Install dependencies: +1. Read [Prerequisites][prereq] and [How to run a sample][run] first. +1. Install dependencies: + + With `npm`: npm install + With `yarn`: + + yarn install + [prereq]: ../README.md#prerequisities [run]: ../README.md#how-to-run-a-sample @@ -37,16 +44,31 @@ __Usage:__ `node projects --help` ``` Commands: - list List all projects the authenticated user has access to. + list List all current projects. Options: - --help Show help [boolean] + --help Show help [boolean] Examples: - node projects list List projects. + node projects.js list Lists all current projects. -For more information, see https://cloud.google.com/resource-manager/docs/ +For more information, see https://cloud.google.com/resource-manager/docs ``` [projects_docs]: https://cloud.google.com/resource-manager/docs/ [projects_code]: projects.js + +## Running the tests + +1. Set the `GCLOUD_PROJECT` and `GOOGLE_APPLICATION_CREDENTIALS` environment + variables. + +1. Run the tests: + + With `npm`: + + npm test + + With `yarn`: + + yarn test diff --git a/packages/google-cloud-resourcemanager/samples/package.json b/packages/google-cloud-resourcemanager/samples/package.json index 2dc8b6a3b33..ac273d8b6d8 100644 --- a/packages/google-cloud-resourcemanager/samples/package.json +++ b/packages/google-cloud-resourcemanager/samples/package.json @@ -2,16 +2,33 @@ "name": "nodejs-docs-samples-resource-manager", "version": "0.0.1", "private": true, - "license": "Apache Version 2.0", + "license": "Apache-2.0", "author": "Google Inc.", - "scripts": { - "test": "cd ..; npm run st -- --verbose resource/system-test/*.test.js" + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, - "dependencies": { - "@google-cloud/resource": "0.6.0", - "yargs": "6.6.0" + "cloud": { + "requiresKeyFile": true, + "requiresProjectId": true }, "engines": { "node": ">=4.3.2" + }, + "scripts": { + "lint": "samples lint", + "pretest": "npm run lint", + "system-test": "ava -T 20s --verbose system-test/*.test.js", + "test": "npm run system-test" + }, + "dependencies": { + "@google-cloud/resource": "0.7.1", + "yargs": "7.1.0" + }, + "devDependencies": { + "@google-cloud/nodejs-repo-tools": "1.3.1", + "ava": "0.19.1", + "proxyquire": "1.7.11", + "sinon": "2.1.0" } } diff --git a/packages/google-cloud-resourcemanager/samples/quickstart.js b/packages/google-cloud-resourcemanager/samples/quickstart.js index ada6428551e..c8ae933591b 100644 --- a/packages/google-cloud-resourcemanager/samples/quickstart.js +++ b/packages/google-cloud-resourcemanager/samples/quickstart.js @@ -1,5 +1,5 @@ /** - * Copyright 2016, Google, Inc. + * 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 @@ -34,5 +34,8 @@ resourceClient.getProjects() console.log('Projects:'); projects.forEach((project) => console.log(project.id)); + }) + .catch((err) => { + console.error('ERROR:', err); }); // [END resource_quickstart]