Skip to content

Commit 3e0fc01

Browse files
tests: fix snippet tests in sandbox env (#2199)
1 parent 661dc82 commit 3e0fc01

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

+7
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-node/test/index.js

+15
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)