@@ -237,7 +237,7 @@ describe('File', () => {
237237 retryOptions : {
238238 autoRetry : true ,
239239 maxRetries : 3 ,
240- retryDelayMultipier : 2 ,
240+ retryDelayMultiplier : 2 ,
241241 totalTimeout : 600 ,
242242 maxRetryDelay : 60 ,
243243 retryableErrorFn : ( err : HTTPError ) => {
@@ -282,7 +282,7 @@ describe('File', () => {
282282 assert . strictEqual ( file . storage , BUCKET . storage ) ;
283283 } ) ;
284284
285- it ( 'should set instanceRetryValue to the storage insance retryOptions.autoRetry value' , ( ) => {
285+ it ( 'should set instanceRetryValue to the storage instance retryOptions.autoRetry value' , ( ) => {
286286 assert . strictEqual (
287287 file . instanceRetryValue ,
288288 STORAGE . retryOptions . autoRetry
@@ -1815,7 +1815,7 @@ describe('File', () => {
18151815 autoRetry : true ,
18161816 maxRetries : 3 ,
18171817 maxRetryDelay : 60 ,
1818- retryDelayMultipier : 2 ,
1818+ retryDelayMultiplier : 2 ,
18191819 totalTimeout : 600 ,
18201820 } ,
18211821 preconditionOpts : {
@@ -1860,8 +1860,8 @@ describe('File', () => {
18601860 options . retryOptions . maxRetryDelay
18611861 ) ;
18621862 assert . strictEqual (
1863- opts . retryOptions . retryDelayMultipier ,
1864- options . retryOptions . retryDelayMultipier
1863+ opts . retryOptions . retryDelayMultiplier ,
1864+ options . retryOptions . retryDelayMultiplier
18651865 ) ;
18661866 assert . strictEqual (
18671867 opts . retryOptions . totalTimeout ,
@@ -1898,7 +1898,7 @@ describe('File', () => {
18981898 autoRetry : true ,
18991899 maxRetries : 3 ,
19001900 maxRetryDelay : 60 ,
1901- retryDelayMultipier : 2 ,
1901+ retryDelayMultiplier : 2 ,
19021902 totalTimeout : 600 ,
19031903 } ,
19041904 } ;
@@ -1939,8 +1939,8 @@ describe('File', () => {
19391939 options . retryOptions . maxRetryDelay
19401940 ) ;
19411941 assert . strictEqual (
1942- opts . retryOptions . retryDelayMultipier ,
1943- options . retryOptions . retryDelayMultipier
1942+ opts . retryOptions . retryDelayMultiplier ,
1943+ options . retryOptions . retryDelayMultiplier
19441944 ) ;
19451945 assert . strictEqual (
19461946 opts . retryOptions . totalTimeout ,
@@ -1996,11 +1996,11 @@ describe('File', () => {
19961996 'Cannot provide an `offset` without providing a `uri`'
19971997 ) ;
19981998
1999- const opitons = {
1999+ const options = {
20002000 offset : 1 ,
20012001 isPartialUpload : true ,
20022002 } ;
2003- const writable = file . createWriteStream ( opitons ) ;
2003+ const writable = file . createWriteStream ( options ) ;
20042004
20052005 writable . on ( 'error' , ( err : RangeError ) => {
20062006 assert . deepEqual ( err , error ) ;
@@ -2490,6 +2490,7 @@ describe('File', () => {
24902490
24912491 describe ( 'download' , ( ) => {
24922492 let fileReadStream : Readable ;
2493+ let originalSetEncryptionKey : Function ;
24932494
24942495 beforeEach ( ( ) => {
24952496 fileReadStream = new Readable ( ) ;
@@ -2502,6 +2503,13 @@ describe('File', () => {
25022503 file . createReadStream = ( ) => {
25032504 return fileReadStream ;
25042505 } ;
2506+
2507+ originalSetEncryptionKey = file . setEncryptionKey ;
2508+ file . setEncryptionKey = sinon . stub ( ) ;
2509+ } ) ;
2510+
2511+ afterEach ( ( ) => {
2512+ file . setEncryptionKey = originalSetEncryptionKey ;
25052513 } ) ;
25062514
25072515 it ( 'should accept just a callback' , done => {
@@ -2532,6 +2540,31 @@ describe('File', () => {
25322540 file . download ( readOptions , assert . ifError ) ;
25332541 } ) ;
25342542
2543+ it ( 'should call setEncryptionKey with the provided key and not pass it to createReadStream' , done => {
2544+ const encryptionKey = Buffer . from ( 'encryption-key' ) ;
2545+ const downloadOptions = {
2546+ encryptionKey : encryptionKey ,
2547+ userProject : 'user-project-id' ,
2548+ } ;
2549+
2550+ file . createReadStream = ( options : { } ) => {
2551+ assert . deepStrictEqual ( options , { userProject : 'user-project-id' } ) ;
2552+ return fileReadStream ;
2553+ } ;
2554+
2555+ file . download ( downloadOptions , ( err : Error ) => {
2556+ assert . ifError ( err ) ;
2557+ // Verify that setEncryptionKey was called with the correct key
2558+ assert . ok (
2559+ ( file . setEncryptionKey as sinon . SinonStub ) . calledWith ( encryptionKey )
2560+ ) ;
2561+ done ( ) ;
2562+ } ) ;
2563+
2564+ fileReadStream . push ( 'some data' ) ;
2565+ fileReadStream . push ( null ) ;
2566+ } ) ;
2567+
25352568 it ( 'should only execute callback once' , done => {
25362569 Object . assign ( fileReadStream , {
25372570 _read ( this : Readable ) {
@@ -2886,7 +2919,7 @@ describe('File', () => {
28862919 ) ;
28872920 } ) ;
28882921
2889- it ( 'should add ACL condtion ' , done => {
2922+ it ( 'should add ACL condition ' , done => {
28902923 file . generateSignedPostPolicyV2 (
28912924 {
28922925 expires : Date . now ( ) + 2000 ,
@@ -3118,7 +3151,7 @@ describe('File', () => {
31183151 ) ;
31193152 } ) ;
31203153
3121- it ( 'should throw if prexif condition is not an array' , ( ) => {
3154+ it ( 'should throw if prefix condition is not an array' , ( ) => {
31223155 assert . throws ( ( ) => {
31233156 file . generateSignedPostPolicyV2 (
31243157 {
@@ -4525,7 +4558,7 @@ describe('File', () => {
45254558 }
45264559 }
45274560
4528- describe ( 'retry mulipart upload' , ( ) => {
4561+ describe ( 'retry multipart upload' , ( ) => {
45294562 it ( 'should save a string with no errors' , async ( ) => {
45304563 const options = { resumable : false } ;
45314564 file . createWriteStream = ( ) => {
0 commit comments