diff --git a/src/test/storage-test.js b/src/test/storage-test.js index e254687f3..893cc4876 100644 --- a/src/test/storage-test.js +++ b/src/test/storage-test.js @@ -102,23 +102,19 @@ describe('Storage', function () { }); }); - it('can download file', function (done) { + it('can download file', async function () { const sourceFile = gTmpFolder + '/uploadtest/test.txt'; - filesystem.download(gBackupConfig, sourceFile, function (error, stream) { - expect(error).to.be(null); - expect(stream).to.be.an('object'); - done(); - }); + const [error, stream] = await safe(filesystem.download(gBackupConfig, sourceFile)); + expect(error).to.be(null); + expect(stream).to.be.an('object'); }); - it('download errors for missing file', function (done) { + it('download errors for missing file', async function () { const sourceFile = gTmpFolder + '/uploadtest/missing'; - filesystem.download(gBackupConfig, sourceFile, function (error) { - expect(error.reason).to.be(BoxError.NOT_FOUND); - done(); - }); + const [error] = await safe(filesystem.download(gBackupConfig, sourceFile)); + expect(error.reason).to.be(BoxError.NOT_FOUND); }); it('list dir lists the source dir', function (done) { @@ -173,11 +169,9 @@ describe('Storage', function () { }); }); - it('can download file', function (done) { - noop.download(gBackupConfig, 'file', function (error) { - expect(error).to.be.an(Error); - done(); - }); + it('can download file', async function () { + const [error] = await safe(noop.download(gBackupConfig, 'file')); + expect(error).to.be.an(Error); }); it('list dir contents of source dir', function (done) { @@ -237,13 +231,11 @@ describe('Storage', function () { }); }); - it('can download file', function (done) { + it('can download file', async function () { const sourceKey = 'uploadtest/test.txt'; - s3.download(gBackupConfig, sourceKey, function (error, stream) { - expect(error).to.be(null); - expect(stream).to.be.an('object'); - done(); - }); + const [error, stream] = await safe(s3.download(gBackupConfig, sourceKey)); + expect(error).to.be(null); + expect(stream).to.be.an('object'); }); it('list dir lists contents of source dir', function (done) { @@ -379,13 +371,11 @@ describe('Storage', function () { }); }); - it('can download file', function (done) { + it('can download file', async function () { const sourceKey = 'uploadtest/test.txt'; - gcs.download(gBackupConfig, sourceKey, function (error, stream) { - expect(error).to.be(null); - expect(stream).to.be.an('object'); - done(); - }); + const [error, stream] = await safe(gcs.download(gBackupConfig, sourceKey)); + expect(error).to.be(null); + expect(stream).to.be.an('object'); }); it('list dir lists contents of source dir', function (done) {