Skip to content

Commit adeea6a

Browse files
tests: fix snippet tests in sandbox env (#2199)
1 parent 9a5ebc9 commit adeea6a

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

packages/google-cloud-speech/src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ Speech.detectEncoding_ = function(filename) {
161161
* @private
162162
*/
163163
Speech.findFile_ = function(file, callback) {
164+
if (global.GCLOUD_SANDBOX_ENV) {
165+
callback(null, {
166+
content: new Buffer('')
167+
});
168+
return;
169+
}
170+
164171
if (common.util.isCustomType(file, 'storage/file')) {
165172
// File is an instance of module:storage/file.
166173
callback(null, {

packages/google-cloud-speech/test/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,21 @@ describe('Speech', function() {
211211
});
212212

213213
describe('findFile_', function() {
214+
it('should return buffer for snippet sandbox', function(done) {
215+
global.GCLOUD_SANDBOX_ENV = true;
216+
217+
Speech.findFile_({}, function(err, foundFile) {
218+
delete global.GCLOUD_SANDBOX_ENV;
219+
assert.ifError(err);
220+
221+
assert.deepEqual(foundFile, {
222+
content: new Buffer('')
223+
});
224+
225+
done();
226+
});
227+
});
228+
214229
it('should convert a File object', function(done) {
215230
var file = {
216231
bucket: {

0 commit comments

Comments
 (0)