Skip to content

Commit 2d5928f

Browse files
jmdobryAce Nassri
authored andcommitted
Cleanup App Engine samples and re-work tests. (#354)
1 parent a21f930 commit 2d5928f

3 files changed

Lines changed: 55 additions & 13 deletions

File tree

packages/google-cloud-resourcemanager/samples/README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ programmatically manage these container resources.
1616
* [Setup](#setup)
1717
* [Samples](#samples)
1818
* [Projects](#projects)
19+
* [Running the tests](#running-the-tests)
1920

2021
## Setup
2122

22-
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
23-
1. Install dependencies:
23+
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
24+
1. Install dependencies:
25+
26+
With `npm`:
2427

2528
npm install
2629

30+
With `yarn`:
31+
32+
yarn install
33+
2734
[prereq]: ../README.md#prerequisities
2835
[run]: ../README.md#how-to-run-a-sample
2936

@@ -37,16 +44,31 @@ __Usage:__ `node projects --help`
3744

3845
```
3946
Commands:
40-
list List all projects the authenticated user has access to.
47+
list List all current projects.
4148
4249
Options:
43-
--help Show help [boolean]
50+
--help Show help [boolean]
4451
4552
Examples:
46-
node projects list List projects.
53+
node projects.js list Lists all current projects.
4754
48-
For more information, see https://cloud.google.com/resource-manager/docs/
55+
For more information, see https://cloud.google.com/resource-manager/docs
4956
```
5057

5158
[projects_docs]: https://cloud.google.com/resource-manager/docs/
5259
[projects_code]: projects.js
60+
61+
## Running the tests
62+
63+
1. Set the `GCLOUD_PROJECT` and `GOOGLE_APPLICATION_CREDENTIALS` environment
64+
variables.
65+
66+
1. Run the tests:
67+
68+
With `npm`:
69+
70+
npm test
71+
72+
With `yarn`:
73+
74+
yarn test

packages/google-cloud-resourcemanager/samples/package.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,33 @@
22
"name": "nodejs-docs-samples-resource-manager",
33
"version": "0.0.1",
44
"private": true,
5-
"license": "Apache Version 2.0",
5+
"license": "Apache-2.0",
66
"author": "Google Inc.",
7-
"scripts": {
8-
"test": "cd ..; npm run st -- --verbose resource/system-test/*.test.js"
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
910
},
10-
"dependencies": {
11-
"@google-cloud/resource": "0.6.0",
12-
"yargs": "6.6.0"
11+
"cloud": {
12+
"requiresKeyFile": true,
13+
"requiresProjectId": true
1314
},
1415
"engines": {
1516
"node": ">=4.3.2"
17+
},
18+
"scripts": {
19+
"lint": "samples lint",
20+
"pretest": "npm run lint",
21+
"system-test": "ava -T 20s --verbose system-test/*.test.js",
22+
"test": "npm run system-test"
23+
},
24+
"dependencies": {
25+
"@google-cloud/resource": "0.7.1",
26+
"yargs": "7.1.0"
27+
},
28+
"devDependencies": {
29+
"@google-cloud/nodejs-repo-tools": "1.3.1",
30+
"ava": "0.19.1",
31+
"proxyquire": "1.7.11",
32+
"sinon": "2.1.0"
1633
}
1734
}

packages/google-cloud-resourcemanager/samples/quickstart.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016, Google, Inc.
2+
* Copyright 2017, Google, Inc.
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
55
* You may obtain a copy of the License at
@@ -34,5 +34,8 @@ resourceClient.getProjects()
3434

3535
console.log('Projects:');
3636
projects.forEach((project) => console.log(project.id));
37+
})
38+
.catch((err) => {
39+
console.error('ERROR:', err);
3740
});
3841
// [END resource_quickstart]

0 commit comments

Comments
 (0)