From 903d4959ea2433565eba1a79478af8b6638a50b7 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Wed, 4 Nov 2015 14:56:12 -0800 Subject: [PATCH] Add deployment tests. Closes #21. --- .gitignore | 4 +- .travis.yml | 64 +-- README.md | 120 +++++- appengine/README.md | 29 -- appengine/express/README.md | 48 +-- appengine/express/app.yaml | 1 - appengine/express/package.json | 2 +- appengine/geddy/README.md | 67 +--- appengine/geddy/app.yaml | 1 - appengine/geddy/package.json | 7 +- appengine/grunt/README.md | 57 +-- appengine/grunt/app.yaml | 1 - appengine/grunt/package.json | 4 +- appengine/hapi/README.md | 66 +--- appengine/hapi/app.yaml | 1 - appengine/hapi/package.json | 2 +- appengine/koa/README.md | 64 +-- appengine/koa/app.yaml | 1 - appengine/koa/package.json | 2 +- appengine/kraken/README.md | 46 +-- appengine/kraken/app.yaml | 1 - appengine/kraken/package.json | 2 +- appengine/loopback/README.md | 45 +-- appengine/loopback/app.yaml | 1 - appengine/loopback/package.json | 2 +- appengine/mailgun/README.md | 69 +--- appengine/mailgun/app.yaml | 1 - appengine/mailgun/package.json | 2 +- appengine/redis/README.md | 60 +-- appengine/redis/app.yaml | 1 - appengine/redis/package.json | 2 +- appengine/restify/README.md | 74 +--- appengine/restify/app.yaml | 1 - appengine/restify/package.json | 2 +- appengine/sails/README.md | 46 +-- appengine/sails/app.yaml | 1 - appengine/sails/package.json | 2 +- nodejs-docs-samples.json.enc | Bin 2048 -> 0 bytes package.json | 38 +- storage/README.md | 27 ++ storage/authSample.js | 47 ++- storage/package.json | 13 + test/appengine/all.test.js | 406 ++++++++++++++++++++ test/appengine/express.test.js | 49 +++ test/appengine/test.js | 189 --------- test/encrypted/nodejs-docs-samples.json.enc | Bin 0 -> 2320 bytes test/storage/authSample.test.js | 43 +++ test/storage/testAuthSample.js | 28 -- 48 files changed, 855 insertions(+), 884 deletions(-) delete mode 100644 appengine/README.md delete mode 100644 nodejs-docs-samples.json.enc create mode 100644 storage/README.md create mode 100644 storage/package.json create mode 100644 test/appengine/all.test.js create mode 100644 test/appengine/express.test.js delete mode 100644 test/appengine/test.js create mode 100644 test/encrypted/nodejs-docs-samples.json.enc create mode 100644 test/storage/authSample.test.js delete mode 100644 test/storage/testAuthSample.js diff --git a/.gitignore b/.gitignore index d49592be1d..750b6a2cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ **/node_modules/** npm-debug.log -coverage/ \ No newline at end of file +coverage/ + +test/encrypted/nodejs-docs-samples.json diff --git a/.travis.yml b/.travis.yml index dce4356f0c..7c015d2c48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,21 @@ -sudo: false +# Copyright 2015, 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. + +sudo: required language: node_js node_js: - "stable" +- "0.12" - "0.10" cache: @@ -20,38 +34,30 @@ cache: services: - redis-server + - docker env: -- PATH=$PATH:$HOME/gcloud/google-cloud-sdk/bin GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/nodejs-docs-samples.json TEST_BUCKET_NAME=cloud-samples-tests TEST_PROJECT_ID=cloud-samples-tests #Other environment variables on same line + - PATH=$PATH:$HOME/gcloud/google-cloud-sdk/bin GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/test/encrypted/nodejs-docs-samples.json TEST_BUCKET_NAME=nodejs-docs-samples TEST_PROJECT_ID=nodejs-docs-samples #Other environment variables on same line before_install: -#ENCRYPT YOUR PRIVATE KEY (If you need authentication) -# 1. Install and login to the Travis CLI: -# $ gem install travis -# $ travis login -# 2. Move your json private key to client_secrets.json -# 3. Run: -# $ travis encrypt-file client_secrets.json --add -# 4. Commit changes: -# $ git add client_secrets.json.enc -# $ git commit client_secrets.json.enc .travis.yml - -- if [ ! -d $HOME/gcloud/google-cloud-sdk ]; then - mkdir -p $HOME/gcloud && - wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz --directory-prefix=$HOME/gcloud && - cd $HOME/gcloud && - tar xzf google-cloud-sdk.tar.gz && - printf '\ny\n\ny\ny\n' | ./google-cloud-sdk/install.sh && - cd $TRAVIS_BUILD_DIR; - fi -- openssl aes-256-cbc -K $encrypted_95e832a36b06_key -iv $encrypted_95e832a36b06_iv -in nodejs-docs-samples.json.enc -out nodejs-docs-samples.json -d -- if [ -a nodejs-docs-samples.json ]; then - gcloud auth activate-service-account --key-file nodejs-docs-samples.json; - fi - -install: -#Add app specific setup here -#Use '-q' to disable interactive prompts + - if [ ! -d $HOME/gcloud/google-cloud-sdk ]; then + mkdir -p $HOME/gcloud && + wget https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz --directory-prefix=$HOME/gcloud && + cd $HOME/gcloud && + tar xzf google-cloud-sdk.tar.gz && + printf '\ny\n\ny\ny\n' | ./google-cloud-sdk/install.sh && + source /home/travis/.bash_profile && + cd $TRAVIS_BUILD_DIR; + fi + - gcloud components update -q + - gcloud components update app -q + - openssl aes-256-cbc -K $encrypted_fda0b707c7d5_key -iv $encrypted_fda0b707c7d5_iv -in test/encrypted/nodejs-docs-samples.json.enc -out test/encrypted/nodejs-docs-samples.json -d + - if [ -a test/encrypted/nodejs-docs-samples.json ]; then + gcloud auth activate-service-account --key-file test/encrypted/nodejs-docs-samples.json; + fi after_success: - npm run coveralls + +after_script: + - gsutil -m cp *.log gs://nodejs-docs-samples-travis-deployments diff --git a/README.md b/README.md index 48b8598498..9d0e8df248 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,48 @@ # Google Cloud Platform NodeJS Samples -This repository holds the samples used in the nodejs documentation on [cloud.google.com/nodejs](https://cloud.google.com/nodejs). +This repository holds the samples used in the nodejs documentation on +[cloud.google.com/nodejs](https://cloud.google.com/nodejs). [![Build Status](https://travis-ci.org/GoogleCloudPlatform/nodejs-docs-samples.svg)](https://travis-ci.org/GoogleCloudPlatform/nodejs-docs-samples) ## Google App Engine -This is a collection of samples and instructions to run common nodejs frameworks and applications on [Google App Engine](http://cloud.google.com/nodejs). +This is a collection of samples and instructions to run common nodejs frameworks +and applications on [Google App Engine](http://cloud.google.com/nodejs). ### Frameworks -- [Express](appengine/express/) -- [Hapi](appengine/hapi/) -- [Loopback](appengine/loopback/) -- [Sails](appengine/sails/) -- [Koa](appengine/koa/) -- [Kraken](appengine/kraken/) -- [Restify](appengine/restify/) -- [Geddy](appengine/geddy/) +- Express.js - [Source code][express_1] | [App Engine Tutorial][express_2] | [Live demo][express_3] | [Documentation][express_4] +- Geddy.js - [Source code][geddy_1] | [App Engine Tutorial][geddy_2] | [Live demo][geddy_3] | [Documentation][geddy_4] +- Hapi.js - [Source code][hapi_1] | [App Engine Tutorial][hapi_2] | [Live demo][hapi_3] | [Documentation][hapi_4] +- Loopback.js - [Source code][loopback_1] | [App Engine Tutorial][loopback_2] | [Live demo][loopback_3] | [Documentation][loopback_4] +- Koa.js - [Source code][koa_1] | [App Engine Tutorial][koa_2] | [Live demo][koa_3] | [Documentation][koa_4] +- Kraken.js - [Source code][kraken_1] | [App Engine Tutorial][kraken_2] | [Live demo][kraken_3] | [Documentation][kraken_4] +- Restify.js - [Source code][restify_1] | [App Engine Tutorial][restify_2] | [Live demo][restify_3] | [Documentation][restify_4] +- Sails.js - [Source code][sails_1] | [App Engine Tutorial][sails_2] | [Live demo][sails_3] | [Documentation][sails_4] -### Services +### Databases -- [Redis](appengine/redis/) +- Redis - [Source code][redis_1] | [App Engine Tutorial][redis_2] | [Documentation][redis_3] ### Tools -- [Grunt](appengine/grunt/) +- gcloud-node - [Source code][gcloud_1] | [Documentation][gcloud_2] +- Grunt.js - [Source code][grunt_1] | [App Engine Tutorial][grunt_2] | [Live demo][grunt_3] | [Documentation][grunt_4] +- Mailgun - [Source code][mailgun_1] | [App Engine Tutorial][mailgun_2] | [Documentation][mailgun_3] -### More information +## Google Storage + +- Auth sample - [Source code][storage_1] | [Google Cloud Docs][storage_2] + +## Example Apps + +- nodejs-getting-started - [Source code][nodejs_1] | [App Engine Tutorial 1][nodejs_2] | [App Engine Tutorial 2][nodejs_3] +- gcloud-node-todos - [Source code][todos_1] +- gitnpm - [Source code][gitnpm_1] +- gcloud-kvstore - [Source code][kvstore_1] + +## More information - [Getting started with nodejs on Google Cloud](http://cloud.google.com/nodejs/) - See our other [Google Cloud Platform github repos](https://github.com/GoogleCloudPlatform) for sample applications and scaffolding for other frameworks and use cases. @@ -36,8 +51,81 @@ This is a collection of samples and instructions to run common nodejs frameworks ## Contributing changes -* See [CONTRIBUTING.md](CONTRIBUTING.md) +Contributions welcome! + +See [CONTRIBUTING.md](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md) ## Licensing -* See [LICENSE](LICENSE) +Apache Version 2.0 + +See [LICENSE](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/LICENSE) + +[storage_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/storage/authSample.js +[storage_2]: https://cloud.google.com/storage/docs/authentication#acd-examples + +[express_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/express +[express_2]: https://cloud.google.com/nodejs/resources/frameworks/express +[express_3]: http://express-dot-nodejs-docs-samples.appspot.com +[express_4]: http://expressjs.com/ + +[geddy_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/geddy +[geddy_2]: https://cloud.google.com/nodejs/resources/frameworks/geddy +[geddy_3]: http://geddy-dot-nodejs-docs-samples.appspot.com +[geddy_4]: http://geddyjs.org/ + +[hapi_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/hapi +[hapi_2]: https://cloud.google.com/nodejs/resources/frameworks/hapi +[hapi_3]: http://hapi-dot-nodejs-docs-samples.appspot.com +[hapi_4]: http://hapijs.com/ + +[loopback_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/loopback +[loopback_2]: https://cloud.google.com/nodejs/resources/frameworks/loopback +[loopback_3]: http://loopback-dot-nodejs-docs-samples.appspot.com +[loopback_4]: http://loopback.io/ + +[koa_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/koa +[koa_2]: https://cloud.google.com/nodejs/resources/frameworks/koa +[koa_3]: http://koa-dot-nodejs-docs-samples.appspot.com +[koa_4]: http://koajs.com/ + +[kraken_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/kraken +[kraken_2]: https://cloud.google.com/nodejs/resources/frameworks/kraken +[kraken_3]: http://kraken-dot-nodejs-docs-samples.appspot.com +[kraken_4]: http://krakenjs.com/ + +[restify_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/restify +[restify_2]: https://cloud.google.com/nodejs/resources/frameworks/restify +[restify_3]: http://restify-dot-nodejs-docs-samples.appspot.com +[restify_4]: http://restify.com/ + +[sails_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/sails +[sails_2]: https://cloud.google.com/nodejs/resources/frameworks/sails +[sails_3]: http://sails-dot-nodejs-docs-samples.appspot.com +[sails_4]: http://sailsjs.org/ + +[redis_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/redis +[redis_2]: https://cloud.google.com/nodejs/resources/databases/redis +[redis_3]: http://redis.io/ + +[gcloud_1]: https://github.com/GoogleCloudPlatform/gcloud-node +[gcloud_2]: https://googlecloudplatform.github.io/gcloud-node/#/ + +[grunt_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/grunt +[grunt_2]: https://cloud.google.com/nodejs/resources/tools/grunt +[grunt_3]: http://grunt-dot-nodejs-docs-samples.appspot.com +[grunt_4]: http://gruntjs.com/ + +[mailgun_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/mailgun +[mailgun_2]: https://cloud.google.com/nodejs/resources/tools/mailgun +[mailgun_3]: http://www.mailgun.com/ + +[nodejs_1]: https://github.com/GoogleCloudPlatform/nodejs-getting-started +[nodejs_2]: https://cloud.google.com/nodejs/getting-started/hello-world +[nodejs_3]: https://cloud.google.com/nodejs/getting-started/tutorial-app + +[todos_1]: https://github.com/GoogleCloudPlatform/gcloud-node-todos + +[gitnpm_1]: https://github.com/stephenplusplus/gitnpm + +[kvstore_1]: https://github.com/stephenplusplus/gcloud-kvstore \ No newline at end of file diff --git a/appengine/README.md b/appengine/README.md deleted file mode 100644 index 10a0953ea9..0000000000 --- a/appengine/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# nodejs -> Google App Engine - -This is a collection of samples and instructions to run common nodejs frameworks and applications on [Google App Engine](http://cloud.google.com/nodejs). - -## Frameworks - -- [Express](express/) -- [Hapi](hapi/) -- [Loopback](/loopback) -- [Sails](sails/) -- [Koa](koa/) -- [Kraken](kraken/) -- [Restify](restify/) -- [Geddy](geddy/) - -## Services - -- [Redis](redis/) - -## Tools - -- [Grunt](grunt/) - -## More info - -- [Getting started with nodejs on Google Cloud](http://cloud.google.com/nodejs/) -- [Using the `gcloud` npm module](https://googlecloudplatform.github.io/gcloud-node/#/) -- [Logging to Google Cloud with Winston](https://github.com/GoogleCloudPlatform/winston-gae) - \ No newline at end of file diff --git a/appengine/express/README.md b/appengine/express/README.md index 120b836d62..bdde6b81a3 100644 --- a/appengine/express/README.md +++ b/appengine/express/README.md @@ -1,43 +1,13 @@ -## Express on Google App Engine +## Express.js on Google App Engine -> [Express](http://expressjs.com) is a minimal and flexible Node.js web -application framework that provides a robust set of features for web and mobile -applications. +> [Express][1] is a minimal and flexible Node.js web application framework that +provides a robust set of features for web and mobile applications. -You can view the deployed demo app [here](https://express-demo.appspot.com). +Read the [Express.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Express app +You can also view the [live demo][3] and read the [Express.js documentation][1]. -View the [Express app generator guide](http://expressjs.com/starter/generator.html). - -### Configure - -Create an `app.yaml` in the root of your application with the following -contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "node ./bin/www", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://expressjs.com/ +[2]: https://cloud.google.com/nodejs/resources/frameworks/express +[3]: http://express-dot-nodejs-docs-samples.appspot.com diff --git a/appengine/express/app.yaml b/appengine/express/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/express/app.yaml +++ b/appengine/express/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/express/package.json b/appengine/express/package.json index 8027ff3317..642668f959 100644 --- a/appengine/express/package.json +++ b/appengine/express/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node ./bin/www", - "deploy": "gcloud preview app deploy app.yaml --promote --project express-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "body-parser": "^1.14.1", diff --git a/appengine/geddy/README.md b/appengine/geddy/README.md index 09abadc355..6af84aad39 100644 --- a/appengine/geddy/README.md +++ b/appengine/geddy/README.md @@ -1,62 +1,13 @@ -## Geddy on Google App Engine +## Geddy.js on Google App Engine -> [Geddy](http://geddyjs.org/) is a simple, structured web framework for Node. +> [Geddy][1] is a simple, structured web framework for Node. -You can view the deployed demo app [here](https://geddy-demo.appspot.com). +Read the [Geddy.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Geddy app +You can also view the [live demo][3] and read the [Geddy.js documentation][4]. -[View the Geddy tutorial](http://geddyjs.org/tutorial). - -### Configure - -Create an `app.yaml` in the root of your application with the following -contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Prepare the app - -If you haven't already, install the Geddy CLI: - -``` -$ npm install -g geddy -``` - -Create a `config/secrets.json` file: - -``` -$ echo "{}" > config/secrets.json -``` - -Generate an app secret: - -``` -$ geddy gen secret -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "node node_modules/geddy/bin/cli.js", - "debug": "node node_modules/geddy/bin/cli.js --debug", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://geddyjs.org/ +[2]: https://cloud.google.com/nodejs/resources/frameworks/geddy +[3]: http://geddy-dot-nodejs-docs-samples.appspot.com +[4]: http://geddyjs.org/tutorial diff --git a/appengine/geddy/app.yaml b/appengine/geddy/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/geddy/app.yaml +++ b/appengine/geddy/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/geddy/package.json b/appengine/geddy/package.json index 42fd7117c1..518c1177d5 100644 --- a/appengine/geddy/package.json +++ b/appengine/geddy/package.json @@ -8,9 +8,10 @@ "node": "~0.12.7" }, "scripts": { - "start": "node node_modules/geddy/bin/cli.js", - "debug": "node node_modules/geddy/bin/cli.js --debug", - "deploy": "gcloud preview app deploy app.yaml --promote --project geddy-demo" + "prestart": "GEDDY_SECRET=config/secrets.json; [[ -f $GEDDY_SECRET ]] || echo '{}' > $GEDDY_SECRET && geddy gen secret", + "start": "geddy", + "debug": "geddy --debug", + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "geddy": "^13.0.8" diff --git a/appengine/grunt/README.md b/appengine/grunt/README.md index a651a4d2c6..4785d5f553 100644 --- a/appengine/grunt/README.md +++ b/appengine/grunt/README.md @@ -1,53 +1,14 @@ -## Grunt on Google App Engine +## Grunt.js on Google App Engine -> [Grunt](http://gruntjs.com/): The JavaScript Task Runner. +> [Grunt][1]: The JavaScript Task Runner. -You can view the deployed demo app [here](https://gruntjs-demo.appspot.com). +Read the [Grunt.js + Express.js on App Engine Tutorial][2] for how to run and +deploy this sample app. -### Create a new app +You can also view the [live demo][3] and read the [Grunt.js documentation][4]. -[View the Grunt docs](http://gruntjs.com/getting-started). -### Configure - -Create an `app.yaml` in the root of your application with the following -contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - NPM_CONFIG_DEV: true - PORT: 8080 -``` - -Run `npm install --save-dev grunt-cli` to make the Grunt command line tools -available locally during the build. - -### Deploy - -Modify your `package.json` to include an npm `postinstall` script. This will -be run during your applications `npm install` phase. - -For convenience, you can use an npm script to run the deploy command. Modify -your `package.json` to include: - -```json -"scripts": { - "start": "node ./src/bin/www", - "postinstall": "./node_modules/grunt-cli/bin/grunt build", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` - -The `postinstall` script causes the `grunt build` command to be executed after -the `npm install` command succeeds. This allows you to execute the build after -deployment. +[1]: http://gruntjs.com/ +[2]: https://cloud.google.com/nodejs/resources/tools/grunt +[3]: http://grunt-dot-nodejs-docs-samples.appspot.com +[4]: http://gruntjs.com/getting-started diff --git a/appengine/grunt/app.yaml b/appengine/grunt/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/grunt/app.yaml +++ b/appengine/grunt/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/grunt/package.json b/appengine/grunt/package.json index d31949828a..02a76f95ed 100644 --- a/appengine/grunt/package.json +++ b/appengine/grunt/package.json @@ -9,8 +9,8 @@ }, "scripts": { "start": "node ./src/bin/www", - "postinstall": "./node_modules/grunt-cli/bin/grunt build", - "deploy": "gcloud preview app deploy app.yaml --promote --project gruntjs-demo" + "postinstall": "grunt build", + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "body-parser": "^1.14.1", diff --git a/appengine/hapi/README.md b/appengine/hapi/README.md index d83b46ee97..8f045db934 100644 --- a/appengine/hapi/README.md +++ b/appengine/hapi/README.md @@ -1,59 +1,15 @@ -## Hapi on Google App Engine +## Hapi.js on Google App Engine -> [Hapi](http://hapijs.com/) is a rich framework for building applications and services. Hapi enabled developers to focus on writing reusable application logic instead of spending time building infrastructure. +> [Hapi][1] is a rich framework for building applications and services. Hapi +enabled developers to focus on writing reusable application logic instead of +spending time building infrastructure. -You can view the deployed demo app [here](https://hapi-demo.appspot.com). +Read the [Hapi.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Hapi app +You can also view the [live demo][3] and read the [Hapi.js documentation][4]. -[View the Hapi docs](http://hapijs.com/). - -### Configure - -Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Prepare the app - -Update `package.json` to add an `npm start` command: - -```json -"scripts": { - "start": "node index.js", -} -``` - -Update the port in `index.js` to use `process.env.PORT || 8080`, and `0.0.0.0`: - -```js -server.connection({ - host: '0.0.0.0', - port: process.env.PORT || 8080 -}); -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "node index.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://hapijs.com/ +[2]: https://cloud.google.com/nodejs/resources/frameworks/hapi +[3]: http://hapi-dot-nodejs-docs-samples.appspot.com +[4]: http://hapijs.com/ diff --git a/appengine/hapi/app.yaml b/appengine/hapi/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/hapi/app.yaml +++ b/appengine/hapi/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/hapi/package.json b/appengine/hapi/package.json index b8aa73f512..93c7efdc2e 100644 --- a/appengine/hapi/package.json +++ b/appengine/hapi/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node index.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project hapi-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "hapi": "^10.5.0" diff --git a/appengine/koa/README.md b/appengine/koa/README.md index 4d93ccc3f6..854a72410d 100644 --- a/appengine/koa/README.md +++ b/appengine/koa/README.md @@ -1,60 +1,12 @@ -## Koa on Google App Engine +## Koa.js on Google App Engine -> [koa](http://koajs.com) is a next generation web framework for node.js +> [koa][1] is a next generation web framework for node.js -You can view the deployed demo app [here](https://koa-demo.appspot.com). +Read the [Koa.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Koa app +You can also view the [live demo][3] and read the [Koa.js documentation][1]. -[View the Koa docs](http://koajs.com/). - -Start by creating an `app.js`: - -```js -var koa = require('koa'); -var app = koa(); - -app.use(function *(){ - this.body = 'Hello World'; -}); - -app.listen(process.env.PORT || 8080); -``` - -### Configure - -Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Prepare the app - -Run `npm init` to initialize a `package.json`. - -Modify your `package.json`. Add a `start` command - take care to include the -`--harmony` flag, as Koa.js requires generators. - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "node --harmony app.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://koajs.com +[2]: https://cloud.google.com/nodejs/resources/frameworks/koa +[3]: http://koa-dot-nodejs-docs-samples.appspot.com diff --git a/appengine/koa/app.yaml b/appengine/koa/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/koa/app.yaml +++ b/appengine/koa/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/koa/package.json b/appengine/koa/package.json index ad36c47d72..f10e21185d 100644 --- a/appengine/koa/package.json +++ b/appengine/koa/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node --harmony app.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project koa-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "koa": "^1.0.0" diff --git a/appengine/kraken/README.md b/appengine/kraken/README.md index 2484a10330..c80f059e5d 100644 --- a/appengine/kraken/README.md +++ b/appengine/kraken/README.md @@ -1,40 +1,14 @@ -## Kraken on Google App Engine +## Kraken.js on Google App Engine -> [Kraken](http://krakenjs.com) is a secure and scalable layer that extends express by providing structure and convention. +> [Kraken][1] is a secure and scalable layer that extends express by providing +structure and convention. -You can view the deployed demo app [here](https://kraken-demo.appspot.com). +Read the [Kraken.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Kraken app +You can also view the [live demo][3] and read the [Kraken.js documentation][4]. -[View the Kraken docs](http://krakenjs.com/index.html#getting-started). - -### Configure - -Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://krakenjs.com +[2]: https://cloud.google.com/nodejs/resources/frameworks/kraken +[3]: http://kraken-dot-nodejs-docs-samples.appspot.com +[4]: http://krakenjs.com/index.html#getting-started diff --git a/appengine/kraken/app.yaml b/appengine/kraken/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/kraken/app.yaml +++ b/appengine/kraken/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/kraken/package.json b/appengine/kraken/package.json index 3231b2328c..c9616ad7e5 100644 --- a/appengine/kraken/package.json +++ b/appengine/kraken/package.json @@ -12,7 +12,7 @@ "build": "node_modules/grunt-cli/bin/grunt build", "all": "npm run build && npm run test", "start": "node server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project kraken-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "construx": "^1.0.0", diff --git a/appengine/loopback/README.md b/appengine/loopback/README.md index 6218f96723..e80d7fb9e3 100644 --- a/appengine/loopback/README.md +++ b/appengine/loopback/README.md @@ -1,40 +1,13 @@ -## Loopback on Google App Engine +## Loopback.js on Google App Engine -> [Loopback](http://loopback.io/) is a highly-extensible, open-source Node.js framework. +> [Loopback][1] is a highly-extensible, open-source Node.js framework. -You can view the deployed demo app [here](https://strongloop-demo.appspot.com). +Read the [Loopback.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Loopback app +You can also view the [live demo][3] and read the [Loopback.js documentation][4]. -[View the Loopback docs](http://loopback.io/getting-started/). - -### Configure - -Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "node server/server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project [project id]" -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://loopback.io/ +[2]: https://cloud.google.com/nodejs/resources/frameworks/loopback +[3]: http://loopback-dot-nodejs-docs-samples.appspot.com +[4]: http://loopback.io/getting-started/ diff --git a/appengine/loopback/app.yaml b/appengine/loopback/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/loopback/app.yaml +++ b/appengine/loopback/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/loopback/package.json b/appengine/loopback/package.json index f555dba405..47e6fcc539 100644 --- a/appengine/loopback/package.json +++ b/appengine/loopback/package.json @@ -10,7 +10,7 @@ "scripts": { "pretest": "jshint .", "start": "node server/server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project strongloop-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "compression": "^1.0.3", diff --git a/appengine/mailgun/README.md b/appengine/mailgun/README.md index 385913ece1..ad303e4925 100644 --- a/appengine/mailgun/README.md +++ b/appengine/mailgun/README.md @@ -1,63 +1,20 @@ -## Mailgun on Google App Engine with Node.js +## Express.js + Mailgun on Google App Engine -> [Mailgun](https://www.mailgun.com/): The Email Service For Developers +> [Mailgun][1]: The Email Service For Developers > > – www.mailgun.com -This sample application demonstrates how to use -[Express.js](http://expressjs.com) and -[node-mailgun](http://github.com/shz/node-mailgun) to send transactional email -on [Google App Engine](https://cloud.google.com/appengine). +This sample application demonstrates how to use [Express.js][2] and +[node-mailgun][3] to send transactional email on [Google App Engine][4]. -### Sign up for Mailgun +Read the [Mailgun on App Engine Tutorial][5] for how to run and deploy this +sample app. -1. Sign up for a [Mailgun account](https://mailgun.com/signup). -1. Add a [new domain](https://mailgun.com/app/domains). -1. Find your API key in your new domain's settings. +You can also read the [Mailgun documentation][6]. -### Configure - -Add these lines to the `app.yaml` file in the root of your application: - -```yaml -env_variables: - PORT: 8080 - MAILGUN_API_KEY: -``` - -### Start the app locally - -``` -$ export MAILGUN_API_KEY= -$ npm start -``` - -Now visit http://localhost:8080 and try sending yourself an email. - -When the app is deployed to Google Cloud Platform the `MAILGUN_API_KEY` -environment variable will be set to the value specified in `app.yaml`. - -### Deploy - -Ensure your gcloud sdk is setup by running: - -``` -$ gcloud init -``` - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "start": "node app.js", - "deploy": "gcloud preview app deploy app.yaml --promote" -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: https://www.mailgun.com/ +[2]: http://expressjs.com +[3]: http://github.com/shz/node-mailgun +[4]: https://cloud.google.com/appengine +[5]: https://cloud.google.com/nodejs/resources/tools/mailgun +[6]: https://documentation.mailgun.com/ diff --git a/appengine/mailgun/app.yaml b/appengine/mailgun/app.yaml index 4d8ff91802..4f89c8e7de 100644 --- a/appengine/mailgun/app.yaml +++ b/appengine/mailgun/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 MAILGUN_API_KEY: diff --git a/appengine/mailgun/package.json b/appengine/mailgun/package.json index 691626aa55..dba227c31c 100644 --- a/appengine/mailgun/package.json +++ b/appengine/mailgun/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node app.js", - "deploy": "gcloud preview app deploy app.yaml --promote" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "body-parser": "^1.14.1", diff --git a/appengine/redis/README.md b/appengine/redis/README.md index 2aafc2d29c..16d73d6c08 100644 --- a/appengine/redis/README.md +++ b/appengine/redis/README.md @@ -1,57 +1,13 @@ ## Redis on Google App Engine -> [Redis](http://redis.io/) is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. +> [Redis][1] is an open source (BSD licensed), in-memory data structure store, +used as database, cache and message broker. -##### Start a Redis server +Read the [Redis on App Engine Tutorial][2] for how to run and deploy this sample +app. -There are multiple options to creating a new redis server: -- Create a GCE virtual machine with redis preinstalled -- Use [Redis Labs](https://redislabs.com/signup-gce-lp1) to create a free Redis-as-a-Service account +You can also read the [node_redis documentation][3]. -###### Sign up for a redis labs account - -To sign up for a new redis labs account: - -1. Create a new redis subscription -2. Choose the cloud `GCE/us-central1` -3. Choose the free tier -4. Click `select` -5. Choose a resource name and password -6. Place your host name, port, and key into a json file. - -Here's an example json file: - -```json -{ - "redisHost": "pub-redis-*****.us-central1-1-1.gce.garantiadata.com", - "redisPort": ******, - "redisKey": "******" -} -``` - -Make sure to not check this file into source control by adding `keys.json` to your `.gitignore`. - -##### Configure - -Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -##### Deploy - -For convenience, you can use an npm script to run the deploy command. Modify your `package.json` to include: - -```json -"scripts": { - "start": "node server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run `npm run deploy` to deploy your application. +[1]: http://redis.io/ +[2]: https://cloud.google.com/nodejs/resources/databases/redis +[3]: https://github.com/NodeRedis/node_redis diff --git a/appengine/redis/app.yaml b/appengine/redis/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/redis/app.yaml +++ b/appengine/redis/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/redis/package.json b/appengine/redis/package.json index d521cd67cb..cb98d8a827 100644 --- a/appengine/redis/package.json +++ b/appengine/redis/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project node-redis-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "nconf": "^0.8.0", diff --git a/appengine/restify/README.md b/appengine/restify/README.md index e86b100023..e11e318abf 100644 --- a/appengine/restify/README.md +++ b/appengine/restify/README.md @@ -1,69 +1,13 @@ -## Restify on Google App Engine +## Restify.js on Google App Engine -> [Restify](http://mcavage.me/node-restify/) is a node.js module built specifically to enable you to build correct REST web services. +> [Restify][1] is a node.js module built specifically to enable you to build +correct REST web services. -You can view the deployed demo app [here](https://restify-demo.appspot.com). +Read the [Restify.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Restify app +You can also view the [live demo][3] and read the [Restify.js documentation][1]. -Create a new directory for your code. - -Run `npm init` and follow the prompts. - -Create a `server.js` with the following code: - -```js -var restify = require('restify'); - -var server = restify.createServer({ - name: 'appengine-restify', - version: '1.0.0' -}); - -server.use(restify.acceptParser(server.acceptable)); -server.use(restify.queryParser()); -server.use(restify.bodyParser()); - -server.get('/echo/:name', function (req, res, next) { - res.send(req.params); - return next(); -}); - -server.get('/', function (req, res, next) { - res.send("restify on appengine") -}); - -server.listen(process.env.PORT || 8080, function () { - console.log('%s listening at %s', server.name, server.url); -}); -``` - -Run `npm install --save restify` - -### Configure Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://restify.com/ +[2]: https://cloud.google.com/nodejs/resources/frameworks/restify +[3]: http://restify-dot-nodejs-docs-samples.appspot.com diff --git a/appengine/restify/app.yaml b/appengine/restify/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/restify/app.yaml +++ b/appengine/restify/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/restify/package.json b/appengine/restify/package.json index 1f3135b98d..181ab6dc2f 100644 --- a/appengine/restify/package.json +++ b/appengine/restify/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "node server.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project restify-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "restify": "^4.0.0" diff --git a/appengine/sails/README.md b/appengine/sails/README.md index 35ba865afb..e228fa0c8e 100644 --- a/appengine/sails/README.md +++ b/appengine/sails/README.md @@ -1,41 +1,13 @@ -## Sails on Google App Engine +## Sails.js on Google App Engine -> [Sails](http://sailsjs.org/) makes it easy to build custom, enterprise-grade Node.js apps. +> [Sails][1] makes it easy to build custom, enterprise-grade Node.js apps. -You can view the deployed demo app [here](https://sails-demo.appspot.com). +Read the [Sails.js on App Engine Tutorial][2] for how to run and deploy this +sample app. -### Create a new Sails app +You can also view the [live demo][3] and read the [Sails.js documentation][4]. -[View the Sails docs](http://sailsjs.org/get-started) - -### Configure - -Create an `app.yaml` in the root of your application with the following contents: - -```yaml -runtime: nodejs -vm: true -api_version: 1 -env_variables: - PORT: 8080 -``` - -### Deploy - -For convenience, you can use an npm script to run the `gcloud` command. Add -these lines to your `package.json` file: - -```json -"scripts": { - "debug": "node debug app.js", - "start": "node app.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project " -} -``` - -At the terminal you can now run the following command to deploy your -application: - -``` -$ npm deploy -``` \ No newline at end of file +[1]: http://sailsjs.org/ +[2]: https://cloud.google.com/nodejs/resources/frameworks/sails +[3]: http://sails-dot-nodejs-docs-samples.appspot.com +[4]: http://sailsjs.org/get-started diff --git a/appengine/sails/app.yaml b/appengine/sails/app.yaml index 09725ea77f..7176b385a4 100644 --- a/appengine/sails/app.yaml +++ b/appengine/sails/app.yaml @@ -14,7 +14,6 @@ # [START app_yaml] runtime: nodejs vm: true -api_version: 1 env_variables: PORT: 8080 # [END app_yaml] \ No newline at end of file diff --git a/appengine/sails/package.json b/appengine/sails/package.json index 5a89bbf067..7948de6745 100644 --- a/appengine/sails/package.json +++ b/appengine/sails/package.json @@ -10,7 +10,7 @@ "scripts": { "debug": "node debug app.js", "start": "node app.js", - "deploy": "gcloud preview app deploy app.yaml --promote --project sails-demo" + "deploy": "gcloud preview app deploy app.yaml" }, "dependencies": { "ejs": "^2.3.4", diff --git a/nodejs-docs-samples.json.enc b/nodejs-docs-samples.json.enc deleted file mode 100644 index b07eabf98de97f95f74a7012083f24d527ffb863..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2048 zcmV+b2>!dJ}T6`CZMYNtU@_YtK(^`}#qOLr=P<~U&Z?#1r|Ced0U|3EB zBW;RvQv8A`js+PZQS{-k;Afs%s1hFlN+a@P${UoFE-Jfa6B6b|7%$@Vni@nU81es? zXgdd}LpNMk^H;#txUy6pd_W&Qt&G5}w=&{U$-=;>xWKqGze%d&(07f6S5`SN_A`ed zp5Kd1M$S?=DAzO`cnKiYD4J-LDsAxF-dmd_w@W8)Af= zxn0|949F`wnCG`O1u}w4X?>vF-;l@{9~WRCFz*f^vh~5oR6hPqA*y|$fo_CY}q;S zpwdIcpqp!1Gvr$n09Y~Lk*d?Z*$kqt;YwAXmTnG%p?<$8 zj0SGtZ~+ohEm!aF$b=hv%sbJj+8lOUrw{b)2a(pO9RfqBb%8~INamJUpkG91z?_O- z6!(jM2VL*Ozj%tWr^Tr7ac;tFo72x=jJzXanX42E*F96Ip!4ho%Aspd3#v-3B+6c= zgJVO%o8Yc>P5D5}jf9eWo1*r$k}Mn=~@xum;d2`}V+v+#(m5FK~U^mU%$EzO9GSm{D+)_tR6&!3`)!mDqL3q~bl&z!^i%cJuz=7>+)n(0|R{ zOT^t2sTuI=n4DK^P?h_8wqirFoSA^C{yWhtG8C*q$K_nkwX#wy3G*TN`CDboRslG~ z+SXC`|M_6XRbo%$m%V$h*(ORQsN!n;WPqIW4*wfH-~+9F`B>T&Y2<1XgiWo7Zm-N2 za%E=-!H~pI20iVBe~D}j3+nSF=hmzq#&L-XFurI!_!+_{6XWst%d25!Wnd<$UUe5p zwhc*9_qNg*whQi{`~PKtyTcr?^gQF4tcHh{YTM`}k<#w#f~ppuYurcvUNQw+4q_Y$mNEv~h3Z<)8Bto4rw6>-#3LKv@NziweotCJRANNF02HPSdc6{l) zZjUIM?d1iN=B#oCB&*Mq-_RT!x2iObCQjbQC%?AXbVM@hRI-<2V5XV`-n(kHkSO|I zz7Z!5hl{JxBdANU43COQ2WGiCmPGaWY{S&>PTvRuQr0*0{X17GY`OgqOKUC0hCys^Rg%54U0aGQ2OEFc;a~_hFF0GRkWnv7< zHMdKT#{KE%9Omc zSx|vnWRob+BwFU$oGs;~oj^+eaGl~9{JD0Ac&QV3PhG|v9*GO*ehOCD&o70!tU7pj z$r?RjMZcdr($%a2mpJ0Xbt3+Vg!9w>_Xfznn{46v%hUL#|9myucb&7qtsyFzo|*4kEhvghr#r%IlV)*r* ze=zmA6Z|t$539co)Z9R?n+9+uxHShi**Vnz?0EzydW;Gln5Z2eu;%c_BZQ1DHu|>@ z2{Ng=HH}0WCsfqDxO67_3$z0SXKs*lg2IpM$6Unok)Pu $GEDDY_SECRET && node node_modules/.bin/geddy gen secret; cd ../..;", + "pretest": "npm run pretest_express && npm run pretest_geddy", + "test": "npm run jshint && npm run cover" }, "devDependencies": { + "async": "^1.5.0", "coveralls": "^2.11.4", + "googleapis": "^2.1.6", "istanbul": "^0.4.0", "jshint": "~2.8.0", - "lodash": "~3.10.1", "mocha": "^2.2.5", - "request": "^2.65.0" - }, - "repository": { - "type": "git", - "url": "https://github.com/GoogleCloudPlatform/python-docs-samples.git" + "request": "^2.65.0", + "supertest": "^1.1.0" } } diff --git a/storage/README.md b/storage/README.md new file mode 100644 index 0000000000..40a98a38e9 --- /dev/null +++ b/storage/README.md @@ -0,0 +1,27 @@ +## Storage Samples + +## Run a sample + +Install dependencies: + +``` +$ npm install +``` + +To print available commands: + +``` +$ npm run +``` + +Execute a sample: + +``` +$ npm run -- [arg_1] [arg_2] [arg_n] +``` + +Example: + +``` +$ npm run authSample -- my-cool-project +``` \ No newline at end of file diff --git a/storage/authSample.js b/storage/authSample.js index a9c7429c85..42f537ee5c 100644 --- a/storage/authSample.js +++ b/storage/authSample.js @@ -1,3 +1,16 @@ +// Copyright 2015, 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. + /** * @fileoverview Sample code that grabs default credentials from the * environment, then uses it to make an api call. @@ -10,7 +23,7 @@ var google = require('googleapis'); * Callback for remote requests. * * @callback requestCallback - * @param {Object} error - if there's an error with the request, this is pass + * @param {Object} err - if there's an error with the request, this is pass * through to the callback. * @param {Object} response - the response for the request. */ @@ -18,15 +31,15 @@ var google = require('googleapis'); /** * Fetches a list of the buckets under the given project id. * - * @param {String} projectId - the project id that owns the buckets. - * @param {requestCallback} callback - a function to be called when the server + * @param {String} projectId - The project id that owns the buckets. + * @param {requestCallback} cb - A function to be called when the server * responds with the list of buckets. */ // [START list_buckets] -function listBuckets(projectId, callback) { - google.auth.getApplicationDefault(function(error, authClient) { - if (error) { - return callback(error); +function listBuckets(projectId, cb) { + google.auth.getApplicationDefault(function(err, authClient) { + if (err) { + return cb(err); } // Depending on the environment that provides the default credentials @@ -45,11 +58,23 @@ function listBuckets(projectId, callback) { storage.buckets.list({ auth: authClient, project: projectId - }, callback); + }, cb); }); } // [END list_buckets] -module.exports = { - listBuckets: listBuckets -}; +exports.listBuckets = listBuckets; + +// For command-line execution of sample +if (module === require.main) { + listBuckets( + process.argv.length > 2 ? process.argv[2] : '', + function (err, response) { + if (err) { + console.log(err); + } else if (response && response.items) { + console.log(JSON.stringify(response.items, null, 2)); + } + } + ); +} diff --git a/storage/package.json b/storage/package.json new file mode 100644 index 0000000000..ea474984df --- /dev/null +++ b/storage/package.json @@ -0,0 +1,13 @@ +{ + "name": "nodejs-docs-samples-storage", + "description": "Node.js samples for Google Cloud Storage.", + "version": "0.0.1", + "private": true, + "license": "Apache Version 2.0", + "scripts": { + "authSample": "node authSample.js" + }, + "dependencies": { + "googleapis": "^2.1.6" + } +} diff --git a/test/appengine/all.test.js b/test/appengine/all.test.js new file mode 100644 index 0000000000..f8e7e995d9 --- /dev/null +++ b/test/appengine/all.test.js @@ -0,0 +1,406 @@ +// Copyright 2015, 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'; + +var spawn = require('child_process').spawn; +var request = require('request'); +var fs = require('fs'); +var async = require('async'); +var cwd = process.cwd(); +var projectId = process.env.TEST_PROJECT_ID || 'nodejs-docs-samples'; + +function getPath(dir) { + return cwd + '/appengine/' + dir; +} + +var sampleTests = [ + { + dir: 'express', + deploy: true, + promote: true, + cmd: 'node', + args: ['./bin/www'], + msg: 'Hello World! Express.js on Google App Engine.', + TRAVIS_NODE_VERSION: '0.10' + }, + { + dir: 'geddy', + deploy: true, + cmd: 'node', + args: ['node_modules/geddy/bin/cli.js'], + msg: 'Hello, World! Geddy.js on Google App Engine.', + TRAVIS_NODE_VERSION: '0.10' + }, + { + dir: 'grunt', + deploy: true, + cmd: 'node', + args: ['./src/bin/www'], + msg: 'Hello World! Express.js + Grunt.js on Google App Engine.', + TRAVIS_NODE_VERSION: '0.12' + }, + { + dir: 'hapi', + deploy: true, + cmd: 'node', + args: ['index.js'], + msg: 'Hello World! Hapi.js on Google App Engine.', + TRAVIS_NODE_VERSION: '0.12' + }, + { + dir: 'kraken', + deploy: true, + cmd: 'node', + args: ['server.js'], + msg: 'Hello World! Kraken.js on Google App Engine.', + code: 304, + TRAVIS_NODE_VERSION: '0.12' + }, + { + dir: 'loopback', + deploy: true, + cmd: 'node', + args: ['server/server.js'], + msg: 'LoopBack.js on Google App Engine.', + code: 304, + TRAVIS_NODE_VERSION: 'stable' + }, + { + dir: 'mailgun', + cmd: 'node', + args: ['app.js'], + msg: 'Express.js + Mailgun on Google App Engine.' + }, + // { + // dir: 'redis', + // cmd: 'node', + // args: ['server.js'], + // msg: '127.0.0.1' + // }, + { + dir: 'restify', + deploy: true, + cmd: 'node', + args: ['server.js'], + msg: 'Hello World! Restify.js on Google App Engine.', + TRAVIS_NODE_VERSION: 'stable' + } +]; + +if (process.env.TRAVIS_NODE_VERSION === '0.10') { + // For some reason the "npm install" step for the Sails sample doesn't work on + // Travis when using Node.js stable. It works locally, however. + sampleTests.push({ + dir: 'sails', + deploy: true, + cmd: 'node', + args: ['app.js'], + msg: 'Hello World! Sails.js on Google App Engine.', + timeout: 240000, + TRAVIS_NODE_VERSION: '0.10' + }); +} + +//if (process.env.TRAVIS_NODE_VERSION === 'stable') { + // For some reason the "npm install" step for the Sails sample doesn't work on + // Travis when using Node.js stable. It works locally, however. + sampleTests.push({ + dir: 'koa', + deploy: true, + cmd: 'node', + args: ['--harmony', 'app.js'], + msg: 'Hello World! Koa.js on Google App Engine.', + TRAVIS_NODE_VERSION: 'stable' + }); +//} + +// Send a request to the given url and test that the response body has the +// expected value +function testRequest(url, sample, cb) { + request(url, function (err, res, body) { + if (err) { + // Request error + return cb(err); + } else { + if (body && body.indexOf(sample.msg) !== -1 && + (res.statusCode === 200 || res.statusCode === sample.code)) { + // Success + return cb(null, true); + } else { + // Short-circuit app test + var message = sample.dir + ': failed verification!\n' + + 'Expected: ' + sample.msg + '\n' + + 'Actual: ' + body; + + // Response body did not match expected + return cb(new Error(message)); + } + } + }); +} + +describe('appengine/', function () { + sampleTests.forEach(function (sample) { + it(sample.dir + ': dependencies should install', function (done) { + // Allow extra time for "npm install" + this.timeout(sample.timeout || 120000); + + testInstallation(sample, done); + }); + + it(sample.dir + ' should return 200 and Hello World', function (done) { + testLocalApp(sample, done); + }); + }); + + if (!process.env.TRAVIS) { + return; + } + + it('should deploy all samples', function (done) { + // 30 minutes because deployments are slow + this.timeout(30 * 60 * 1000); + + testDeployments(done); + }); +}); + +function testInstallation(sample, done) { + + // Keep track off whether "done" has been called yet + var calledDone = false; + + var proc = spawn('npm', ['install'], { + cwd: getPath(sample.dir) + }); + + proc.on('error', finish); + + if (!process.env.TRAVIS) { + proc.stderr.on('data', function (data) { + console.log('stderr: ' + data); + }); + } + + proc.on('exit', function (code) { + if (code !== 0) { + finish(new Error(sample.dir + ': failed to install dependencies!')); + } else { + finish(); + } + }); + + // Exit helper so we don't call "cb" more than once + function finish(err) { + if (!calledDone) { + calledDone = true; + done(err); + } + } +} + +function testLocalApp(sample, done) { + var calledDone = false; + + var proc = spawn(sample.cmd, sample.args, { + cwd: getPath(sample.dir) + }); + + proc.on('error', finish); + + if (!process.env.TRAVIS) { + proc.stderr.on('data', function (data) { + console.log('stderr: ' + data); + }); + } + + proc.on('exit', function (code, signal) { + if (code !== 0 && signal !== 'SIGKILL') { + return finish(new Error(sample.dir + ': failed to run!')); + } else { + return finish(); + } + }); + + // Give the server time to start up + setTimeout(function () { + // Test that the app is working + testRequest('http://localhost:8080', sample, function (err) { + proc.kill('SIGKILL'); + setTimeout(function () { + return finish(err); + }, 2000); + }); + }, 5000); + + // Exit helper so we don't call "cb" more than once + function finish(err) { + if (!calledDone) { + calledDone = true; + done(err); + } + } +} + +function testDeployments(done) { + + // Only deploy samples that have a projectId + var samplesToDeploy = sampleTests.filter(function (sample) { + return (sample.deploy && + process.env.TRAVIS_NODE_VERSION === sample.TRAVIS_NODE_VERSION); + }); + + // Create deployment tasks + var tasks = samplesToDeploy.map(function (sample) { + return function (cb) { + // Keep track off whether "cb" has been called yet + var calledDone = false; + // Keep track off whether the logs have fully flushed + var logFinished = false; + + var _cwd = getPath(sample.dir); + var args = [ + 'preview', + 'app', + 'deploy', + 'app.yaml', + // Skip prompt + '-q', + '--project', + projectId, + // Deploy over existing version so we don't have to clean up + '--version', + sample.dir, + // Override any existing deployment + '--force', + sample.promote ? '--promote' : '--no-promote', + // Build locally, much faster + '--docker-build', + 'local', + '--verbosity', + 'debug' + ]; + + console.log(_cwd + ' $ gcloud ' + args.join(' ')); + + var logFile = process.env.TRAVIS_BUILD_DIR + + '/' + + sample.dir + + '-' + + process.env.TRAVIS_BUILD_ID + + '-' + + process.env.TRAVIS_BUILD_NUMBER + + '-' + + process.env.TRAVIS_JOB_ID + + '-' + + process.env.TRAVIS_JOB_NUMBER + + '.log'; + + var logStream = fs.createWriteStream(logFile, { flags: 'a' }); + + // Don't use "npm run deploy" because we need extra flags + var proc = spawn('gcloud', args, { + cwd: _cwd + }); + + // Exit helper so we don't call "cb" more than once + function finish(err, result) { + if (!calledDone) { + calledDone = true; + var intervalId = setInterval(function () { + if (logFinished) { + clearInterval(intervalId); + cb(err, result); + } + }, 1000); + } + } + + logStream.on('finish', function () { + if (!logFinished) { + logFinished = true; + } + }); + + proc.stdout.pipe(logStream, { end: false }); + proc.stderr.pipe(logStream, { end: false }); + + var numEnded = 0; + + function finishLogs() { + numEnded++; + if (numEnded === 2) { + logStream.end(); + console.log('Saved logs for ' + sample.dir + ' to ' + logFile); + } + } + + proc.stdout.on('end', finishLogs); + proc.stderr.on('end', finishLogs); + + // This is called if the process fails to start. "error" event may or may + // not be fired in addition to the "exit" event. + proc.on('error', finish); + + // Process has completed + proc.on('exit', function (code) { + if (code !== 0) { // Deployment failed + // Pass error as second argument so we don't short-circuit the + // parallel tasks + return finish(null, new Error(sample.dir + ': failed to deploy!')); + } else { // Deployment succeeded + // Test that sample app is running successfully + return async.waterfall([ + function (cb) { + // Give apps time to start + setTimeout(cb, 5000); + }, + function (cb) { + // Test versioned url of "default" module + var demoUrl = 'http://' + sample.dir + '-dot-' + projectId + + '.appspot.com'; + testRequest(demoUrl, sample, cb); + } + ], finish); + } + }); + }; + }); + + // Deploy sample apps in parallel + return async.parallel(tasks, function (err, results) { + if (err) { + return done(err); + } else { + var success = true; + var message = ''; + // Find errors that didn't short-circuit the parallel tasks + results.forEach(function (result) { + if (result instanceof Error) { + // Gather error messages + message = message + result.message + '\n'; + success = false; + } else { + // "result" should be "true" for those apps that passed verification + success = success && result; + } + }); + if (success) { + return done(); + } else { + return done(new Error(message)); + } + } + }); +} diff --git a/test/appengine/express.test.js b/test/appengine/express.test.js new file mode 100644 index 0000000000..a05b545413 --- /dev/null +++ b/test/appengine/express.test.js @@ -0,0 +1,49 @@ +// Copyright 2015, 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'; + +var assert = require('assert'); +var request = require('supertest'); +var app = require('../../appengine/express/app.js'); + +describe('express', function () { + it('should return 200 and a "Hello World" message', function (done) { + var message = 'Hello World! Express.js on Google App Engine.'; + + request(app) + .get('/') + .expect(200) + .expect(function (res) { + assert( + res.text.indexOf(message) !== -1, + 'Response should contain a "Hello World" message.\n' + + 'Found: ' + res.text + ); + }) + .end(done); + }); + it('should respond with a resource on the "users" route', function (done) { + request(app) + .get('/users') + .expect(200) + .expect('respond with a resource') + .end(done); + }); + it('should respond with a 404 to unknown request', function (done) { + request(app) + .get('/doesnotexist') + .expect(404) + .end(done); + }); +}); diff --git a/test/appengine/test.js b/test/appengine/test.js deleted file mode 100644 index 74c3030e18..0000000000 --- a/test/appengine/test.js +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2015, 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'; - -var spawn = require('child_process').spawn; -var request = require('request'); - -var cwd = process.cwd(); - -function getPath(dir) { - return cwd + '/appengine/' + dir; -} - -var sampleTests = [ - { - dir: 'express', - cmd: 'node', - arg1: './bin/www', - msg: 'Hello World! Express.js on Google App Engine.' - }, - { - dir: 'geddy', - cmd: 'node', - arg1: 'node_modules/geddy/bin/cli.js', - msg: 'Hello, World! Geddy.js on Google App Engine.' - }, - { - dir: 'grunt', - cmd: 'node', - arg1: './src/bin/www', - msg: 'Hello World! Express.js + Grunt.js on Google App Engine.' - }, - { - dir: 'hapi', - cmd: 'node', - arg1: 'index.js', - msg: 'Hello World! Hapi.js on Google App Engine.' - }, - { - dir: 'kraken', - cmd: 'node', - arg1: 'server.js', - msg: 'Hello World! Kraken.js on Google App Engine.', - code: 304 - }, - { - dir: 'loopback', - cmd: 'node', - arg1: 'server/server.js', - msg: 'LoopBack.js on Google App Engine.', - code: 304 - }, - { - dir: 'mailgun', - cmd: 'node', - arg1: 'app.js', - msg: 'Express.js + Mailgun on Google App Engine.' - }, - { - dir: 'redis', - cmd: 'node', - arg1: 'server.js', - msg: '127.0.0.1' - }, - { - dir: 'restify', - cmd: 'node', - arg1: 'server.js', - msg: 'Hello World! Restify.js on Google App Engine.' - } -]; - -if (process.env.TRAVIS_NODE_VERSION !== 'stable') { - // For some reason the "npm install" step for the Sails sample doesn't work on - // Travis when using Node.js stable. It works locally, however. - sampleTests.push({ - dir: 'sails', - cmd: 'node', - arg1: 'app.js', - msg: 'Hello World! Sails.js on Google App Engine.', - timeout: 240000 - }); -} - -describe('appengine/', function () { - sampleTests.forEach(function (sample) { - it(sample.dir + ': dependencies should install', function (done) { - this.timeout(sample.timeout || 120000); - var calledDone = false; - - var proc = spawn('npm', ['install'], { - cwd: getPath(sample.dir) - }); - - proc.on('error', function (err) { - if (!calledDone) { - calledDone = true; - done(err); - } - }); - - if (!process.env.TRAVIS) { - proc.stderr.on('data', function (data) { - console.log('stderr: ' + data); - }); - } - - proc.on('exit', function (code) { - if (!calledDone) { - calledDone = true; - if (code !== 0) { - done(new Error(sample.dir + ': failed to install dependencies!')); - } else { - done(); - } - } - }); - }); - - it(sample.dir + ': should return 200 and Hello World', function (done) { - var timeoutId; - var intervalId; - var success = false; - var calledDone = false; - - var proc = spawn(sample.cmd, [sample.arg1], { - cwd: getPath(sample.dir) - }); - - proc.on('error', function (err) { - if (!calledDone) { - calledDone = true; - done(err); - } - }); - - if (!process.env.TRAVIS) { - proc.stderr.on('data', function (data) { - console.log('stderr: ' + data); - }); - } - - proc.on('exit', function (code, signal) { - if (!calledDone) { - calledDone = true; - if (code !== 0 && signal !== 'SIGKILL') { - done(new Error(sample.dir + ': failed to run!')); - } else { - if (!success) { - done(new Error(sample.dir + ': failed verification!')); - } else { - done(); - } - } - } - }); - - timeoutId = setTimeout(end, 5000); - intervalId = setInterval(testRequest, 1000); - - function end() { - clearTimeout(timeoutId); - clearInterval(intervalId); - proc.kill('SIGKILL'); - } - - function testRequest() { - request('http://localhost:8080', function (err, res, body) { - if (body && body.indexOf(sample.msg) !== -1 && - (res.statusCode === 200 || res.statusCode === sample.code)) { - success = true; - end(); - } - }); - } - }); - }); -}); diff --git a/test/encrypted/nodejs-docs-samples.json.enc b/test/encrypted/nodejs-docs-samples.json.enc new file mode 100644 index 0000000000000000000000000000000000000000..950c40de0ebc6fa757b438bf32bbb858632f1f1a GIT binary patch literal 2320 zcmV+r3Gen7e(ZaYa?k#GROj`wLhZdzujDen5zE&)+Q~nM`)a&_O{=`(JbwlLT8V+| zsHZ#sxOvP+NIDlr^&IK&Nu%af&XcJACy&1%%8gVTK(!1C%arZ*om*f~P_x)JLN#xU zSH0W&U9GbhYnwy>)KdgeVt|Wz+=QU5UHj7ydTwb(n(8I$*)=QQ@9Cv`(n6gOvpL8K zX#s&#bj>a9a^$sQE>ow}Q&A^3n2Ff`*Sz$~q zmm%-E5$gQ3QH0`3Ovki|A{o0Z(Tt6XR*^^1D^RN;(e;i7CqIaZwaRhMlD_^63Yuv&O26%n^UeOgN@ysPBw9lEl(3U zbP6WupR`DYd}TXHU}k{e5y}~!)})k9;w_>Q`o~P!a4M)mn1--t74}0`F1d|s=*8O{ za8=ns2_s9}B->6b2{6(B{Mnxi0=RqerXn$iZURj{V%LA-GEVUxuY}T{W~^z|CFrCT z<0m_O*+aL-=sQTRNrVe^N#u6}OL#43!3qV$me%XRno6=4UdhN(j;En?w##!4BSuJN zG}=3~1<$Zv=Tn>c^RGKcsP?X12;l>|b4bSs0K|mj6?rfUYp8U4F1v z1ih_}ck<_E2l$_Xj%9WLBW@@64Tfhu%q+i)&Vu^0a~Fs}=2_#o+-Ht8}VBVl;&0Zur{uN?5@w3pe4!+5D?EkzeB4A?EVrsmOY26+Yk3a#K}~ z%g{6H+90_b!^1Nwzak}rd20H$M))yQt@`+}sO4cS?h8xQ|D0%>TYUpr6zaD&oxD_G ziwUs~fBtw{_;cCL^N6VF4L26FdBgNz{A(4R0~QJ&^C>_=*xebY-s*w{=m+!AAR@o- zFbQWy#2V*_5P~+hM79sSGo#B1MBY2QrnHee6`8==Dsn0o#bVszu83Zxui`}fNdA+$ za7N18+`*e!ZU%eye;1Z)Z&0-KEY>PEWZJl6hsrw7`ee;qivpinh53ssw|2GyOv&#w8}>G3 z++gu1%r1Bdwgs`bYKoY$!cw6E9G&Bn#*$b%0>`GPOf`=G$rB03t-Qt7`qiR4#bl%1 zr6+EZ%yY{XNj-Ww`4tN7M&=~)nm$-!2nYBHqi{N~bF){2S`h*{bEUVMOe-W$!skRg-C%VSDPlCV-oEy+~K9mig9iSdpBB@NL16+CCNu2row7gdM zI7P{X)49d&wPd)C;)2RzDI#^oC@H0cM4v@c@aZVApO#g&&s4RgaEfYYZ-pL3u?-vc zf#9-iQ>^m4aJr)QTewh=te5J{2);bjA@!)^2yOhy(O4Z7 zY7`rII}kaBq*L0plqQnwUU8^aIlEN-s7JDeWc-2Ume8{k*Y%8^O}b{rdLKYjo%Y1f z&*T!nnM0ji0xJRcj0Yl!db^9?Y6dHPyq3dGzyg}gFep<}(G@oJYXIO+(QK4vw6oT@ z*=oMEPu8jo9rwUx?1LTxz4$I_7YIKk^}|?<`&`wCtb5!!VxJUqP9a?KNh0XGjQgDq<4^?8K|1Wy!(rZ}XeLok`Zd8lXO`(^S6{xJ!T#9K_0n8b zsUZ=K=fWt(r~|4$P1l&vHi%3|{AAzdq_7 z(O|^n0Lw6TMWC$4=1r4l3aDOe)OFJ{YVRInM(qCz qqmI})kvPe=c>?4Q7rlO?&_2d{2~jviGYb@F#E2XZmIIZSFLR 0, 'There should be some buckets.'); + assert.equal(response.items.filter(function (item) { + return item.name === bucketName; + }).length, 1, 'There should be a bucket named ' + bucketName); + return done(); + } + } + ); + }); +}); diff --git a/test/storage/testAuthSample.js b/test/storage/testAuthSample.js deleted file mode 100644 index c6cf42851f..0000000000 --- a/test/storage/testAuthSample.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @fileoverview Tests for the list-buckets module. - */ -'use strict'; - -var assert = require('assert'); -var _ = require('lodash'); - -var authSample = require('../../storage/authSample'); - -describe('listBuckets', function() { - it('returns a list of buckets', function(done) { - authSample.listBuckets( - process.env.TEST_PROJECT_ID, - function(error, success) { - if (error) { - done('Should not have returned an error: ' + error); - } else { - assert(success.items.length > 0); - assert(_.find(success.items, function(item) { - return item.name === process.env.TEST_BUCKET_NAME; - })); - done(); - } - }); - }); -}); -