|
18 | 18 | 'use strict';
|
19 | 19 |
|
20 | 20 | const path = require('path');
|
21 |
| -const assert = require('assert'); |
22 |
| -const tools = require('@google-cloud/nodejs-repo-tools'); |
| 21 | +const {assert} = require('chai'); |
| 22 | +const execa = require('execa'); |
23 | 23 |
|
24 | 24 | const cmd = 'node analyze.js';
|
25 | 25 | const cwd = path.join(__dirname, '..');
|
26 |
| - |
27 | 26 | const url = 'gs://nodejs-docs-samples-video/quickstart.mp4';
|
28 | 27 | const shortUrl = 'gs://nodejs-docs-samples-video/quickstart_short.mp4';
|
29 | 28 | const file = 'resources/cat.mp4';
|
30 | 29 |
|
31 |
| -// analyze_labels_gcs (one scene) |
32 |
| -it('should analyze labels in a GCS file with one scene', async () => { |
33 |
| - const output = await tools.runAsync(`${cmd} labels-gcs ${shortUrl}`, cwd); |
34 |
| - assert.strictEqual(new RegExp(/Label shirt occurs at:/).test(output), true); |
35 |
| - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); |
36 |
| -}); |
| 30 | +const exec = async cmd => (await execa.shell(cmd, {cwd})).stdout; |
37 | 31 |
|
38 |
| -// analyze_labels_gcs (multiple scenes) |
39 |
| -it('should analyze labels in a GCS file with multiple scenes', async () => { |
40 |
| - const output = await tools.runAsync(`${cmd} labels-gcs ${url}`, cwd); |
41 |
| - assert.strictEqual(new RegExp(/Label shirt occurs at:/).test(output), true); |
42 |
| - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); |
43 |
| -}); |
| 32 | +describe('analyze samples', () => { |
| 33 | + // analyze_labels_gcs (one scene) |
| 34 | + it('should analyze labels in a GCS file with one scene', async () => { |
| 35 | + const output = await exec(`${cmd} labels-gcs ${shortUrl}`); |
| 36 | + assert.match(output, /Label shirt occurs at:/); |
| 37 | + assert.match(output, /Confidence: \d+\.\d+/); |
| 38 | + }); |
44 | 39 |
|
45 |
| -// analyze_labels_local |
46 |
| -it('should analyze labels in a local file', async () => { |
47 |
| - const output = await tools.runAsync(`${cmd} labels-file ${file}`, cwd); |
48 |
| - assert.strictEqual( |
49 |
| - new RegExp(/Label whiskers occurs at:/).test(output), |
50 |
| - true |
51 |
| - ); |
52 |
| - assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); |
53 |
| -}); |
| 40 | + // analyze_labels_gcs (multiple scenes) |
| 41 | + it('should analyze labels in a GCS file with multiple scenes', async () => { |
| 42 | + const output = await exec(`${cmd} labels-gcs ${url}`); |
| 43 | + assert.match(output, /Label shirt occurs at:/); |
| 44 | + assert.match(output, /Confidence: \d+\.\d+/); |
| 45 | + }); |
54 | 46 |
|
55 |
| -// analyze_shots (multiple shots) |
56 |
| -it('should analyze shots in a GCS file with multiple shots', async () => { |
57 |
| - const output = await tools.runAsync(`${cmd} shots ${url}`, cwd); |
58 |
| - assert.strictEqual(new RegExp(/Scene 0 occurs from:/).test(output), true); |
59 |
| -}); |
| 47 | + // analyze_labels_local |
| 48 | + it('should analyze labels in a local file', async () => { |
| 49 | + const output = await exec(`${cmd} labels-file ${file}`); |
| 50 | + assert.match(output, /Label whiskers occurs at:/); |
| 51 | + assert.match(output, /Confidence: \d+\.\d+/); |
| 52 | + }); |
60 | 53 |
|
61 |
| -// analyze_shots (one shot) |
62 |
| -it('should analyze shots in a GCS file with one shot', async () => { |
63 |
| - const output = await tools.runAsync(`${cmd} shots ${shortUrl}`, cwd); |
64 |
| - assert.strictEqual( |
65 |
| - new RegExp(/The entire video is one shot./).test(output), |
66 |
| - true |
67 |
| - ); |
68 |
| -}); |
| 54 | + // analyze_shots (multiple shots) |
| 55 | + it('should analyze shots in a GCS file with multiple shots', async () => { |
| 56 | + const output = await exec(`${cmd} shots ${url}`); |
| 57 | + assert.match(output, /Scene 0 occurs from:/); |
| 58 | + }); |
69 | 59 |
|
70 |
| -// analyze_safe_search |
71 |
| -it('should analyze safe search results in a GCS file', async () => { |
72 |
| - const output = await tools.runAsync(`${cmd} safe-search ${url}`, cwd); |
73 |
| - assert.strictEqual(new RegExp(/Time: \d+\.\d+s/).test(output), true); |
74 |
| - assert.strictEqual( |
75 |
| - new RegExp(/Explicit annotation results:/).test(output), |
76 |
| - true |
77 |
| - ); |
78 |
| -}); |
| 60 | + // analyze_shots (one shot) |
| 61 | + it('should analyze shots in a GCS file with one shot', async () => { |
| 62 | + const output = await exec(`${cmd} shots ${shortUrl}`); |
| 63 | + assert.match(output, /The entire video is one shot./); |
| 64 | + }); |
| 65 | + |
| 66 | + // analyze_safe_search |
| 67 | + it('should analyze safe search results in a GCS file', async () => { |
| 68 | + const output = await exec(`${cmd} safe-search ${url}`); |
| 69 | + assert.match(output, /Time: \d+\.\d+s/); |
| 70 | + assert.match(output, /Explicit annotation results:/); |
| 71 | + }); |
79 | 72 |
|
80 |
| -// analyze_video_transcription |
81 |
| -it('should analyze video transcription results in a GCS file', async () => { |
82 |
| - const output = await tools.runAsync(`${cmd} transcription ${shortUrl}`, cwd); |
83 |
| - assert.strictEqual(new RegExp(/over the pass/).test(output), true); |
| 73 | + // analyze_video_transcription |
| 74 | + it('should analyze video transcription results in a GCS file', async () => { |
| 75 | + const output = await exec(`${cmd} transcription ${shortUrl}`); |
| 76 | + assert.match(output, /over the pass/); |
| 77 | + }); |
84 | 78 | });
|
0 commit comments