Skip to content

Commit

Permalink
test: add sample tests (#90)
Browse files Browse the repository at this point in the history
* test: add sample tests

* fixy

* fixy
  • Loading branch information
JustinBeckwith authored and jkwlui committed Dec 20, 2018
1 parent 393e3e2 commit b7808ff
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/
.nyc_output
package-lock.json
__pycache__
.coverage
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@
"build/src"
],
"scripts": {
"cover": "nyc --reporter=lcov mocha build/test && nyc report",
"docs": "echo no docs 👻",
"lint": "eslint samples/ && npm run check",
"lint": "eslint '**/*.js' && gts check",
"test": "nyc mocha build/test",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"system-test": "mocha build/system-test --timeout 600000",
"check": "gts check",
"clean": "gts clean",
"compile": "tsc -p .",
"fix": "gts fix && eslint --fix 'samples/*.js'",
"fix": "gts fix && eslint --fix '**/*.js'",
"prepare": "npm run compile",
"pretest": "npm run compile",
"posttest": "npm run check",
"presystem-test": "npm run compile"
},
"repository": "googleapis/google-cloud-kvstore",
Expand Down
1 change: 1 addition & 0 deletions samples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
rules:
no-console: off
node/no-missing-require: off
7 changes: 6 additions & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@
"engines": {
"node": ">=8"
},
"files": [
"*.js"
],
"repository": "googleapis/google-cloud-kvstore",
"private": true,
"scripts": {
"test": "mocha system-test"
"test": "mocha system-test --timeout 10000"
},
"dependencies": {
"@google-cloud/datastore": "^2.0.0",
"google-cloud-kvstore": "^5.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
"execa": "^1.0.0",
"mocha": "^5.2.0"
}
}
2 changes: 1 addition & 1 deletion samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const store = new KVStore(datastore);
*/
async function set() {
await store.set('todos', ['eat', 'sleep', 'repeat']);
console.log('Set some values in the datastore.!');
console.log('Set some values in the datastore.');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions samples/system-test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
env:
mocha: true
18 changes: 18 additions & 0 deletions samples/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright 2018 Google LLC
*
* Distributed under MIT license.
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

const {assert} = require('chai');
const execa = require('execa');

describe('quickstart samples', () => {
it('should run the quickstart', async () => {
const {stdout} = await execa.shell('node quickstart');
assert.match(stdout, /Set some values/);
assert.match(stdout, /Got todos:/);
assert.match(stdout, /todos deleted/);
});
});
8 changes: 0 additions & 8 deletions samples/system-test/test.js

This file was deleted.

0 comments on commit b7808ff

Please sign in to comment.