diff --git a/video-intelligence/package.json b/video-intelligence/package.json index fe00cfccd1..780dc0ad18 100644 --- a/video-intelligence/package.json +++ b/video-intelligence/package.json @@ -1,6 +1,5 @@ { "name": "nodejs-docs-samples-videointelligence", - "version": "0.0.1", "private": true, "license": "Apache-2.0", "files": [ @@ -13,14 +12,15 @@ "node": ">=8" }, "scripts": { - "test": "mocha system-test/*.test.js --timeout=600000" + "test": "mocha system-test --timeout=600000" }, "dependencies": { "@google-cloud/video-intelligence": "^1.5.0", "yargs": "^12.0.0" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "^0.25.0" + "chai": "^4.2.0", + "execa": "^1.0.0", + "mocha": "^5.2.0" } } diff --git a/video-intelligence/system-test/analyze.test.js b/video-intelligence/system-test/analyze.test.js index de974a0d0a..ee0dd4ba18 100644 --- a/video-intelligence/system-test/analyze.test.js +++ b/video-intelligence/system-test/analyze.test.js @@ -18,67 +18,61 @@ 'use strict'; const path = require('path'); -const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {assert} = require('chai'); +const execa = require('execa'); const cmd = 'node analyze.js'; const cwd = path.join(__dirname, '..'); - const url = 'gs://nodejs-docs-samples-video/quickstart.mp4'; const shortUrl = 'gs://nodejs-docs-samples-video/quickstart_short.mp4'; const file = 'resources/cat.mp4'; -// analyze_labels_gcs (one scene) -it('should analyze labels in a GCS file with one scene', async () => { - const output = await tools.runAsync(`${cmd} labels-gcs ${shortUrl}`, cwd); - assert.strictEqual(new RegExp(/Label shirt occurs at:/).test(output), true); - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); -}); +const exec = async cmd => (await execa.shell(cmd, {cwd})).stdout; -// analyze_labels_gcs (multiple scenes) -it('should analyze labels in a GCS file with multiple scenes', async () => { - const output = await tools.runAsync(`${cmd} labels-gcs ${url}`, cwd); - assert.strictEqual(new RegExp(/Label shirt occurs at:/).test(output), true); - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); -}); +describe('analyze samples', () => { + // analyze_labels_gcs (one scene) + it('should analyze labels in a GCS file with one scene', async () => { + const output = await exec(`${cmd} labels-gcs ${shortUrl}`); + assert.match(output, /Label shirt occurs at:/); + assert.match(output, /Confidence: \d+\.\d+/); + }); -// analyze_labels_local -it('should analyze labels in a local file', async () => { - const output = await tools.runAsync(`${cmd} labels-file ${file}`, cwd); - assert.strictEqual( - new RegExp(/Label whiskers occurs at:/).test(output), - true - ); - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); -}); + // analyze_labels_gcs (multiple scenes) + it('should analyze labels in a GCS file with multiple scenes', async () => { + const output = await exec(`${cmd} labels-gcs ${url}`); + assert.match(output, /Label shirt occurs at:/); + assert.match(output, /Confidence: \d+\.\d+/); + }); -// analyze_shots (multiple shots) -it('should analyze shots in a GCS file with multiple shots', async () => { - const output = await tools.runAsync(`${cmd} shots ${url}`, cwd); - assert.strictEqual(new RegExp(/Scene 0 occurs from:/).test(output), true); -}); + // analyze_labels_local + it('should analyze labels in a local file', async () => { + const output = await exec(`${cmd} labels-file ${file}`); + assert.match(output, /Label whiskers occurs at:/); + assert.match(output, /Confidence: \d+\.\d+/); + }); -// analyze_shots (one shot) -it('should analyze shots in a GCS file with one shot', async () => { - const output = await tools.runAsync(`${cmd} shots ${shortUrl}`, cwd); - assert.strictEqual( - new RegExp(/The entire video is one shot./).test(output), - true - ); -}); + // analyze_shots (multiple shots) + it('should analyze shots in a GCS file with multiple shots', async () => { + const output = await exec(`${cmd} shots ${url}`); + assert.match(output, /Scene 0 occurs from:/); + }); -// analyze_safe_search -it('should analyze safe search results in a GCS file', async () => { - const output = await tools.runAsync(`${cmd} safe-search ${url}`, cwd); - assert.strictEqual(new RegExp(/Time: \d+\.\d+s/).test(output), true); - assert.strictEqual( - new RegExp(/Explicit annotation results:/).test(output), - true - ); -}); + // analyze_shots (one shot) + it('should analyze shots in a GCS file with one shot', async () => { + const output = await exec(`${cmd} shots ${shortUrl}`); + assert.match(output, /The entire video is one shot./); + }); + + // analyze_safe_search + it('should analyze safe search results in a GCS file', async () => { + const output = await exec(`${cmd} safe-search ${url}`); + assert.match(output, /Time: \d+\.\d+s/); + assert.match(output, /Explicit annotation results:/); + }); -// analyze_video_transcription -it('should analyze video transcription results in a GCS file', async () => { - const output = await tools.runAsync(`${cmd} transcription ${shortUrl}`, cwd); - assert.strictEqual(new RegExp(/over the pass/).test(output), true); + // analyze_video_transcription + it('should analyze video transcription results in a GCS file', async () => { + const output = await exec(`${cmd} transcription ${shortUrl}`); + assert.match(output, /over the pass/); + }); }); diff --git a/video-intelligence/system-test/analyze.v1p2beta1.test.js b/video-intelligence/system-test/analyze.v1p2beta1.test.js index f011f7d9e8..0b57b7a4c2 100644 --- a/video-intelligence/system-test/analyze.v1p2beta1.test.js +++ b/video-intelligence/system-test/analyze.v1p2beta1.test.js @@ -18,11 +18,12 @@ 'use strict'; const path = require('path'); -const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {assert} = require('chai'); +const execa = require('execa'); const cmd = 'node analyze.v1p2beta1.js'; const cwd = path.join(__dirname, '..'); +const exec = async cmd => (await execa.shell(cmd, {cwd})).stdout; const shortUrl = 'gs://nodejs-docs-samples/video/googlework_short.mp4'; const url = 'gs://nodejs-docs-samples/video/cat.mp4'; @@ -30,24 +31,26 @@ const file1 = 'resources/cat.mp4'; const file2 = 'resources/googlework_short.mp4'; const possibleTexts = /Google|GOOGLE|SUR|OMAR|ROTO|Vice President|58oo9|LONDRES|PARIS|METRO|RUE|CARLO/; -it('should detect text in a GCS file', async () => { - const output = await tools.runAsync(`${cmd} video-text-gcs ${shortUrl}`, cwd); - assert.strictEqual(new RegExp(possibleTexts).test(output), true); -}); - -it('should detect text in a local file', async () => { - const output = await tools.runAsync(`${cmd} video-text ${file2}`, cwd); - assert.strictEqual(new RegExp(possibleTexts).test(output), true); -}); - -it('should track objects in a GCS file', async () => { - const output = await tools.runAsync(`${cmd} track-objects-gcs ${url}`, cwd); - assert.strictEqual(new RegExp(/cat/).test(output), true); - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); -}); - -it('should track objects in a local file', async () => { - const output = await tools.runAsync(`${cmd} track-objects ${file1}`, cwd); - assert.strictEqual(new RegExp(/cat/).test(output), true); - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); +describe('analyze v1p2beta1 samples', () => { + it('should detect text in a GCS file', async () => { + const output = await exec(`${cmd} video-text-gcs ${shortUrl}`); + assert.match(output, possibleTexts); + }); + + it('should detect text in a local file', async () => { + const output = await exec(`${cmd} video-text ${file2}`); + assert.match(output, possibleTexts); + }); + + it('should track objects in a GCS file', async () => { + const output = await exec(`${cmd} track-objects-gcs ${url}`); + assert.match(output, /cat/); + assert.match(output, /Confidence: \d+\.\d+/); + }); + + it('should track objects in a local file', async () => { + const output = await exec(`${cmd} track-objects ${file1}`); + assert.match(output, /cat/); + assert.match(output, /Confidence: \d+\.\d+/); + }); }); diff --git a/video-intelligence/system-test/quickstart.test.js b/video-intelligence/system-test/quickstart.test.js index d5722e1ec0..e7a9a93bd3 100644 --- a/video-intelligence/system-test/quickstart.test.js +++ b/video-intelligence/system-test/quickstart.test.js @@ -16,16 +16,15 @@ 'use strict'; const path = require('path'); -const assert = require('assert'); -const tools = require('@google-cloud/nodejs-repo-tools'); +const {assert} = require('chai'); +const execa = require('execa'); const cmd = 'node quickstart.js'; const cwd = path.join(__dirname, '..'); -it('should analyze a hardcoded video', async () => { - const output = await tools.runAsync(cmd, cwd); - assert.strictEqual( - new RegExp(/Label standing occurs at:/).test(output), - true - ); +describe('quickstart samples', () => { + it('should analyze a hardcoded video', async () => { + const {stdout} = await execa.shell(cmd, {cwd}); + assert.match(stdout, /Label standing occurs at:/); + }); });