Skip to content

Commit e00b61c

Browse files
jmdobryAce Nassri
authored and
Ace Nassri
committed
Cleanup App Engine samples and re-work tests. (#354)
1 parent 6225113 commit e00b61c

File tree

6 files changed

+2917
-61
lines changed

6 files changed

+2917
-61
lines changed

speech/package.json

+21-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,35 @@
22
"name": "nodejs-docs-samples-speech",
33
"version": "0.0.1",
44
"private": true,
5-
"license": "Apache Version 2.0",
5+
"license": "Apache-2.0",
66
"author": "Google Inc.",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
10+
},
11+
"cloud": {
12+
"requiresKeyFile": true,
13+
"requiresProjectId": true
14+
},
15+
"engines": {
16+
"node": ">=4.3.2"
17+
},
718
"scripts": {
8-
"test": "cd ..; npm run st -- --verbose speech/system-test/*.test.js"
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"
923
},
1024
"dependencies": {
1125
"@google-cloud/speech": "0.9.0",
1226
"@google-cloud/storage": "1.0.0",
1327
"node-record-lpcm16": "0.3.0",
1428
"yargs": "7.0.2"
1529
},
16-
"engines": {
17-
"node": ">=4.3.2"
30+
"devDependencies": {
31+
"@google-cloud/nodejs-repo-tools": "1.3.1",
32+
"ava": "0.19.1",
33+
"proxyquire": "1.7.11",
34+
"sinon": "2.1.0"
1835
}
1936
}

speech/quickstart.js

+1-1
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

speech/recognize.js

+2-2
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
@@ -273,7 +273,7 @@ function streamingMicRecognize (encoding, sampleRateHertz, languageCode) {
273273
// [END speech_streaming_mic_recognize]
274274
}
275275

276-
require(`yargs`)
276+
require(`yargs`) // eslint-disable-line
277277
.demand(1)
278278
.command(
279279
`sync <filename>`,

speech/system-test/quickstart.test.js

+10-3
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
@@ -15,11 +15,17 @@
1515

1616
'use strict';
1717

18-
require(`../../system-test/_setup`);
19-
2018
const path = require(`path`);
2119
const proxyquire = require(`proxyquire`).noPreserveCache();
20+
const sinon = require(`sinon`);
2221
const speech = proxyquire(`@google-cloud/speech`, {})();
22+
const test = require(`ava`);
23+
24+
const {
25+
checkCredentials,
26+
stubConsole,
27+
restoreConsole
28+
} = require(`@google-cloud/nodejs-repo-tools`);
2329

2430
const fileName = path.join(__dirname, `../resources/audio.raw`);
2531
const config = {
@@ -28,6 +34,7 @@ const config = {
2834
languageCode: `en-US`
2935
};
3036

37+
test.before(checkCredentials);
3138
test.before(stubConsole);
3239
test.after.always(restoreConsole);
3340

speech/system-test/recognize.test.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515

1616
'use strict';
1717

18-
require(`../../system-test/_setup`);
19-
2018
const path = require(`path`);
2119
const storage = require(`@google-cloud/storage`)();
20+
const test = require(`ava`);
2221
const uuid = require(`uuid`);
2322

23+
const {
24+
runAsync
25+
} = require(`@google-cloud/nodejs-repo-tools`);
26+
2427
const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`;
2528
const cmd = `node recognize.js`;
2629
const cwd = path.join(__dirname, `..`);

0 commit comments

Comments
 (0)