15
15
16
16
'use strict' ;
17
17
18
- require ( `../../system-test/_setup` ) ;
19
-
20
18
const path = require ( `path` ) ;
21
19
const storage = require ( `@google-cloud/storage` ) ( ) ;
20
+ const test = require ( `ava` ) ;
21
+ const tools = require ( `@google-cloud/nodejs-repo-tools` ) ;
22
22
const uuid = require ( `uuid` ) ;
23
23
24
24
const bucketName = `nodejs-docs-samples-test-${ uuid . v4 ( ) } ` ;
@@ -38,6 +38,7 @@ const files = [
38
38
} ;
39
39
} ) ;
40
40
41
+ test . before ( tools . checkCredentials ) ;
41
42
test . before ( async ( ) => {
42
43
const [ bucket ] = await storage . createBucket ( bucketName ) ;
43
44
await Promise . all ( files . map ( ( file ) => bucket . upload ( file . localPath ) ) ) ;
@@ -51,123 +52,123 @@ test.after.always(async () => {
51
52
} ) ;
52
53
53
54
test ( `should detect faces in a local file` , async ( t ) => {
54
- const output = await runAsync ( `${ cmd } faces ${ files [ 0 ] . localPath } ` , cwd ) ;
55
+ const output = await tools . runAsync ( `${ cmd } faces ${ files [ 0 ] . localPath } ` , cwd ) ;
55
56
t . true ( output . includes ( `Faces:` ) ) ;
56
57
t . true ( output . includes ( `Face #1:` ) ) ;
57
58
} ) ;
58
59
59
60
test ( `should detect faces in a remote file` , async ( t ) => {
60
- const output = await runAsync ( `${ cmd } faces-gcs ${ bucketName } ${ files [ 0 ] . name } ` , cwd ) ;
61
+ const output = await tools . runAsync ( `${ cmd } faces-gcs ${ bucketName } ${ files [ 0 ] . name } ` , cwd ) ;
61
62
t . true ( output . includes ( `Faces:` ) ) ;
62
63
t . true ( output . includes ( `Face #1:` ) ) ;
63
64
} ) ;
64
65
65
66
test ( `should detect labels in a local file` , async ( t ) => {
66
- const output = await runAsync ( `${ cmd } labels ${ files [ 4 ] . localPath } ` , cwd ) ;
67
+ const output = await tools . runAsync ( `${ cmd } labels ${ files [ 4 ] . localPath } ` , cwd ) ;
67
68
t . true ( output . includes ( `Labels:` ) ) ;
68
69
t . true ( output . includes ( `cat` ) ) ;
69
70
} ) ;
70
71
71
72
test ( `should detect labels in a remote file` , async ( t ) => {
72
- const output = await runAsync ( `${ cmd } labels-gcs ${ bucketName } ${ files [ 4 ] . name } ` , cwd ) ;
73
+ const output = await tools . runAsync ( `${ cmd } labels-gcs ${ bucketName } ${ files [ 4 ] . name } ` , cwd ) ;
73
74
t . true ( output . includes ( `Labels:` ) ) ;
74
75
t . true ( output . includes ( `cat` ) ) ;
75
76
} ) ;
76
77
77
78
test ( `should detect landmarks in a local file` , async ( t ) => {
78
- const output = await runAsync ( `${ cmd } landmarks ${ files [ 1 ] . localPath } ` , cwd ) ;
79
+ const output = await tools . runAsync ( `${ cmd } landmarks ${ files [ 1 ] . localPath } ` , cwd ) ;
79
80
t . true ( output . includes ( `Landmarks:` ) ) ;
80
81
t . true ( output . includes ( `Palace of Fine Arts` ) ) ;
81
82
} ) ;
82
83
83
84
test ( `should detect landmarks in a remote file` , async ( t ) => {
84
- const output = await runAsync ( `${ cmd } landmarks-gcs ${ bucketName } ${ files [ 1 ] . name } ` , cwd ) ;
85
+ const output = await tools . runAsync ( `${ cmd } landmarks-gcs ${ bucketName } ${ files [ 1 ] . name } ` , cwd ) ;
85
86
t . true ( output . includes ( `Landmarks:` ) ) ;
86
87
t . true ( output . includes ( `Palace of Fine Arts` ) ) ;
87
88
} ) ;
88
89
89
90
test ( `should detect text in a local file` , async ( t ) => {
90
- const output = await runAsync ( `${ cmd } text ${ files [ 3 ] . localPath } ` , cwd ) ;
91
+ const output = await tools . runAsync ( `${ cmd } text ${ files [ 3 ] . localPath } ` , cwd ) ;
91
92
t . true ( output . includes ( `Text:` ) ) ;
92
93
t . true ( output . includes ( `System Software Update` ) ) ;
93
94
} ) ;
94
95
95
96
test ( `should detect text in a remote file` , async ( t ) => {
96
- const output = await runAsync ( `${ cmd } text-gcs ${ bucketName } ${ files [ 3 ] . name } ` , cwd ) ;
97
+ const output = await tools . runAsync ( `${ cmd } text-gcs ${ bucketName } ${ files [ 3 ] . name } ` , cwd ) ;
97
98
t . true ( output . includes ( `Text:` ) ) ;
98
99
t . true ( output . includes ( `System Software Update` ) ) ;
99
100
} ) ;
100
101
101
102
test ( `should detect logos in a local file` , async ( t ) => {
102
- const output = await runAsync ( `${ cmd } logos ${ files [ 2 ] . localPath } ` , cwd ) ;
103
+ const output = await tools . runAsync ( `${ cmd } logos ${ files [ 2 ] . localPath } ` , cwd ) ;
103
104
t . true ( output . includes ( `Logos:` ) ) ;
104
105
t . true ( output . includes ( `Google` ) ) ;
105
106
} ) ;
106
107
107
108
test ( `should detect logos in a remote file` , async ( t ) => {
108
- const output = await runAsync ( `${ cmd } logos-gcs ${ bucketName } ${ files [ 2 ] . name } ` , cwd ) ;
109
+ const output = await tools . runAsync ( `${ cmd } logos-gcs ${ bucketName } ${ files [ 2 ] . name } ` , cwd ) ;
109
110
t . true ( output . includes ( `Logos:` ) ) ;
110
111
t . true ( output . includes ( `Google` ) ) ;
111
112
} ) ;
112
113
113
114
test ( `should detect properties in a local file` , async ( t ) => {
114
- const output = await runAsync ( `${ cmd } properties ${ files [ 1 ] . localPath } ` , cwd ) ;
115
+ const output = await tools . runAsync ( `${ cmd } properties ${ files [ 1 ] . localPath } ` , cwd ) ;
115
116
t . true ( output . includes ( `Colors:` ) ) ;
116
117
t . true ( output . split ( `\n` ) . length > 4 , `Multiple colors were detected.` ) ;
117
118
} ) ;
118
119
119
120
test ( `should detect properties in a remote file` , async ( t ) => {
120
- const output = await runAsync ( `${ cmd } properties-gcs ${ bucketName } ${ files [ 1 ] . name } ` , cwd ) ;
121
+ const output = await tools . runAsync ( `${ cmd } properties-gcs ${ bucketName } ${ files [ 1 ] . name } ` , cwd ) ;
121
122
t . true ( output . includes ( `Colors:` ) ) ;
122
123
t . true ( output . split ( `\n` ) . length > 4 , `Multiple colors were detected.` ) ;
123
124
} ) ;
124
125
125
126
test ( `should detect safe-search in a local file` , async ( t ) => {
126
- const output = await runAsync ( `${ cmd } safe-search ${ files [ 4 ] . localPath } ` , cwd ) ;
127
+ const output = await tools . runAsync ( `${ cmd } safe-search ${ files [ 4 ] . localPath } ` , cwd ) ;
127
128
t . true ( output . includes ( `Medical:` ) ) ;
128
129
} ) ;
129
130
130
131
test ( `should detect safe-search in a remote file` , async ( t ) => {
131
- const output = await runAsync ( `${ cmd } safe-search-gcs ${ bucketName } ${ files [ 4 ] . name } ` , cwd ) ;
132
+ const output = await tools . runAsync ( `${ cmd } safe-search-gcs ${ bucketName } ${ files [ 4 ] . name } ` , cwd ) ;
132
133
t . true ( output . includes ( `Medical:` ) ) ;
133
134
} ) ;
134
135
135
136
test ( `should detect crop hints in a local file` , async ( t ) => {
136
- const output = await runAsync ( `${ cmd } crops ${ files [ 2 ] . localPath } ` , cwd ) ;
137
+ const output = await tools . runAsync ( `${ cmd } crops ${ files [ 2 ] . localPath } ` , cwd ) ;
137
138
t . true ( output . includes ( `Crop Hint 0:` ) ) ;
138
139
t . true ( output . includes ( `Bound 2: (280, 43)` ) ) ;
139
140
} ) ;
140
141
141
142
test ( `should detect crop hints in a remote file` , async ( t ) => {
142
- const output = await runAsync ( `${ cmd } crops-gcs ${ bucketName } ${ files [ 2 ] . name } ` , cwd ) ;
143
+ const output = await tools . runAsync ( `${ cmd } crops-gcs ${ bucketName } ${ files [ 2 ] . name } ` , cwd ) ;
143
144
t . true ( output . includes ( `Crop Hint 0:` ) ) ;
144
145
t . true ( output . includes ( `Bound 2: (280, 43)` ) ) ;
145
146
} ) ;
146
147
147
148
test ( `should detect similar web images in a local file` , async ( t ) => {
148
- const output = await runAsync ( `${ cmd } web ${ files [ 5 ] . localPath } ` , cwd ) ;
149
- t . true ( output . includes ( 'Full matches found: 5 ' ) ) ;
149
+ const output = await tools . runAsync ( `${ cmd } web ${ files [ 5 ] . localPath } ` , cwd ) ;
150
+ t . true ( output . includes ( 'Full matches found:' ) ) ;
150
151
t . true ( output . includes ( 'URL: https://cloud.google.com/vision/docs/images/' ) ) ;
151
- t . true ( output . includes ( 'Partial matches found: 5 ' ) ) ;
152
- t . true ( output . includes ( 'Web entities found: 5 ' ) ) ;
152
+ t . true ( output . includes ( 'Partial matches found:' ) ) ;
153
+ t . true ( output . includes ( 'Web entities found:' ) ) ;
153
154
t . true ( output . includes ( 'Description: Google Cloud Platform' ) ) ;
154
155
} ) ;
155
156
156
157
test ( `should detect similar web images in a remote file` , async ( t ) => {
157
- const output = await runAsync ( `${ cmd } web-gcs ${ bucketName } ${ files [ 5 ] . name } ` , cwd ) ;
158
- t . true ( output . includes ( 'Full matches found: 5 ' ) ) ;
158
+ const output = await tools . runAsync ( `${ cmd } web-gcs ${ bucketName } ${ files [ 5 ] . name } ` , cwd ) ;
159
+ t . true ( output . includes ( 'Full matches found:' ) ) ;
159
160
t . true ( output . includes ( 'URL: https://cloud.google.com/vision/docs/images/' ) ) ;
160
- t . true ( output . includes ( 'Partial matches found: 5 ' ) ) ;
161
- t . true ( output . includes ( 'Web entities found: 5 ' ) ) ;
161
+ t . true ( output . includes ( 'Partial matches found:' ) ) ;
162
+ t . true ( output . includes ( 'Web entities found:' ) ) ;
162
163
t . true ( output . includes ( 'Description: Google' ) ) ;
163
164
} ) ;
164
165
165
166
test ( `should read a document from a local file` , async ( t ) => {
166
- const output = await runAsync ( `${ cmd } fulltext ${ files [ 2 ] . localPath } ` , cwd ) ;
167
+ const output = await tools . runAsync ( `${ cmd } fulltext ${ files [ 2 ] . localPath } ` , cwd ) ;
167
168
t . true ( output . includes ( 'Google Cloud Platform' ) ) ;
168
169
} ) ;
169
170
170
171
test ( `should read a document from a remote file` , async ( t ) => {
171
- const output = await runAsync ( `${ cmd } fulltext-gcs ${ bucketName } ${ files [ 2 ] . name } ` , cwd ) ;
172
+ const output = await tools . runAsync ( `${ cmd } fulltext-gcs ${ bucketName } ${ files [ 2 ] . name } ` , cwd ) ;
172
173
t . true ( output . includes ( 'Google Cloud Platform' ) ) ;
173
174
} ) ;
0 commit comments