diff --git a/services/filestore/app/js/FSPersistorManager.js b/services/filestore/app/js/FSPersistor.js similarity index 100% rename from services/filestore/app/js/FSPersistorManager.js rename to services/filestore/app/js/FSPersistor.js diff --git a/services/filestore/app/js/PersistorManager.js b/services/filestore/app/js/PersistorManager.js index cca0cf0f36..bd944a03f7 100644 --- a/services/filestore/app/js/PersistorManager.js +++ b/services/filestore/app/js/PersistorManager.js @@ -14,10 +14,10 @@ if (!settings.filestore.backend) { switch (settings.filestore.backend) { case 'aws-sdk': case 's3': - module.exports = require('./S3PersistorManager') + module.exports = require('./S3Persistor') break case 'fs': - module.exports = require('./FSPersistorManager') + module.exports = require('./FSPersistor') break default: throw new Error(`unknown filestore backend: ${settings.filestore.backend}`) diff --git a/services/filestore/app/js/S3PersistorManager.js b/services/filestore/app/js/S3Persistor.js similarity index 100% rename from services/filestore/app/js/S3PersistorManager.js rename to services/filestore/app/js/S3Persistor.js diff --git a/services/filestore/test/unit/js/FSPersistorManagerTests.js b/services/filestore/test/unit/js/FSPersistorTests.js similarity index 75% rename from services/filestore/test/unit/js/FSPersistorManagerTests.js rename to services/filestore/test/unit/js/FSPersistorTests.js index 3b3b4bf417..ba343c548c 100644 --- a/services/filestore/test/unit/js/FSPersistorManagerTests.js +++ b/services/filestore/test/unit/js/FSPersistorTests.js @@ -7,9 +7,9 @@ const Errors = require('../../../app/js/Errors') chai.use(require('sinon-chai')) chai.use(require('chai-as-promised')) -const modulePath = '../../../app/js/FSPersistorManager.js' +const modulePath = '../../../app/js/FSPersistor.js' -describe('FSPersistorManagerTests', function() { +describe('FSPersistorTests', function() { const stat = { size: 4, isFile: sinon.stub().returns(true) } const fd = 1234 const readStream = 'readStream' @@ -22,7 +22,7 @@ describe('FSPersistorManagerTests', function() { const files = ['animals/wombat.tex', 'vegetables/potato.tex'] const globs = [`${location}/${files[0]}`, `${location}/${files[1]}`] const filteredFilenames = ['animals_wombat.tex', 'vegetables_potato.tex'] - let fs, rimraf, stream, LocalFileWriter, FSPersistorManager, glob + let fs, rimraf, stream, LocalFileWriter, FSPersistor, glob beforeEach(function() { fs = { @@ -41,7 +41,7 @@ describe('FSPersistorManagerTests', function() { deleteFile: sinon.stub().resolves() } } - FSPersistorManager = SandboxedModule.require(modulePath, { + FSPersistor = SandboxedModule.require(modulePath, { requires: { './LocalFileWriter': LocalFileWriter, './Errors': Errors, @@ -57,7 +57,7 @@ describe('FSPersistorManagerTests', function() { describe('sendFile', function() { const localFilesystemPath = '/path/to/local/file' it('should copy the file', async function() { - await FSPersistorManager.promises.sendFile( + await FSPersistor.promises.sendFile( location, files[0], localFilesystemPath @@ -72,33 +72,21 @@ describe('FSPersistorManagerTests', function() { it('should return an error if the file cannot be stored', async function() { stream.pipeline.yields(error) await expect( - FSPersistorManager.promises.sendFile( - location, - files[0], - localFilesystemPath - ) + FSPersistor.promises.sendFile(location, files[0], localFilesystemPath) ).to.eventually.be.rejected.and.have.property('cause', error) }) }) describe('sendStream', function() { it('should send the stream to LocalFileWriter', async function() { - await FSPersistorManager.promises.sendStream( - location, - files[0], - remoteStream - ) + await FSPersistor.promises.sendStream(location, files[0], remoteStream) expect(LocalFileWriter.promises.writeStream).to.have.been.calledWith( remoteStream ) }) it('should delete the temporary file', async function() { - await FSPersistorManager.promises.sendStream( - location, - files[0], - remoteStream - ) + await FSPersistor.promises.sendStream(location, files[0], remoteStream) expect(LocalFileWriter.promises.deleteFile).to.have.been.calledWith( tempFile ) @@ -107,30 +95,26 @@ describe('FSPersistorManagerTests', function() { it('should return the error from LocalFileWriter', async function() { LocalFileWriter.promises.writeStream.rejects(error) await expect( - FSPersistorManager.promises.sendStream(location, files[0], remoteStream) + FSPersistor.promises.sendStream(location, files[0], remoteStream) ).to.eventually.be.rejectedWith(error) }) it('should send the temporary file to the filestore', async function() { - await FSPersistorManager.promises.sendStream( - location, - files[0], - remoteStream - ) + await FSPersistor.promises.sendStream(location, files[0], remoteStream) expect(fs.createReadStream).to.have.been.calledWith(tempFile) }) }) describe('getFileStream', function() { it('should use correct file location', async function() { - await FSPersistorManager.promises.getFileStream(location, files[0], {}) + await FSPersistor.promises.getFileStream(location, files[0], {}) expect(fs.open).to.have.been.calledWith( `${location}/${filteredFilenames[0]}` ) }) it('should pass the options to createReadStream', async function() { - await FSPersistorManager.promises.getFileStream(location, files[0], { + await FSPersistor.promises.getFileStream(location, files[0], { start: 0, end: 8 }) @@ -146,18 +130,14 @@ describe('FSPersistorManagerTests', function() { err.code = 'ENOENT' fs.open.yields(err) - await expect( - FSPersistorManager.promises.getFileStream(location, files[0], {}) - ) + await expect(FSPersistor.promises.getFileStream(location, files[0], {})) .to.eventually.be.rejected.and.be.an.instanceOf(Errors.NotFoundError) .and.have.property('cause', err) }) it('should wrap any other error', async function() { fs.open.yields(error) - await expect( - FSPersistorManager.promises.getFileStream(location, files[0], {}) - ) + await expect(FSPersistor.promises.getFileStream(location, files[0], {})) .to.eventually.be.rejectedWith('failed to open file for streaming') .and.be.an.instanceOf(Errors.ReadError) .and.have.property('cause', error) @@ -181,18 +161,18 @@ describe('FSPersistorManagerTests', function() { it('should return the file size', async function() { expect( - await FSPersistorManager.promises.getFileSize(location, files[0]) + await FSPersistor.promises.getFileSize(location, files[0]) ).to.equal(size) }) it('should throw a NotFoundError if the file does not exist', async function() { await expect( - FSPersistorManager.promises.getFileSize(location, badFilename) + FSPersistor.promises.getFileSize(location, badFilename) ).to.eventually.be.rejected.and.be.an.instanceOf(Errors.NotFoundError) }) it('should wrap any other error', async function() { - await expect(FSPersistorManager.promises.getFileSize(location, 'raccoon')) + await expect(FSPersistor.promises.getFileSize(location, 'raccoon')) .to.eventually.be.rejected.and.be.an.instanceOf(Errors.ReadError) .and.have.property('cause', error) }) @@ -200,28 +180,28 @@ describe('FSPersistorManagerTests', function() { describe('copyFile', function() { it('Should open the source for reading', async function() { - await FSPersistorManager.promises.copyFile(location, files[0], files[1]) + await FSPersistor.promises.copyFile(location, files[0], files[1]) expect(fs.createReadStream).to.have.been.calledWith( `${location}/${filteredFilenames[0]}` ) }) it('Should open the target for writing', async function() { - await FSPersistorManager.promises.copyFile(location, files[0], files[1]) + await FSPersistor.promises.copyFile(location, files[0], files[1]) expect(fs.createWriteStream).to.have.been.calledWith( `${location}/${filteredFilenames[1]}` ) }) it('Should pipe the source to the target', async function() { - await FSPersistorManager.promises.copyFile(location, files[0], files[1]) + await FSPersistor.promises.copyFile(location, files[0], files[1]) expect(stream.pipeline).to.have.been.calledWith(readStream, writeStream) }) }) describe('deleteFile', function() { it('Should call unlink with correct options', async function() { - await FSPersistorManager.promises.deleteFile(location, files[0]) + await FSPersistor.promises.deleteFile(location, files[0]) expect(fs.unlink).to.have.been.calledWith( `${location}/${filteredFilenames[0]}` ) @@ -230,14 +210,14 @@ describe('FSPersistorManagerTests', function() { it('Should propagate the error', async function() { fs.unlink.yields(error) await expect( - FSPersistorManager.promises.deleteFile(location, files[0]) + FSPersistor.promises.deleteFile(location, files[0]) ).to.eventually.be.rejected.and.have.property('cause', error) }) }) describe('deleteDirectory', function() { it('Should call rmdir(rimraf) with correct options', async function() { - await FSPersistorManager.promises.deleteDirectory(location, files[0]) + await FSPersistor.promises.deleteDirectory(location, files[0]) expect(rimraf).to.have.been.calledWith( `${location}/${filteredFilenames[0]}` ) @@ -246,7 +226,7 @@ describe('FSPersistorManagerTests', function() { it('Should propagate the error', async function() { rimraf.yields(error) await expect( - FSPersistorManager.promises.deleteDirectory(location, files[0]) + FSPersistor.promises.deleteDirectory(location, files[0]) ).to.eventually.be.rejected.and.have.property('cause', error) }) }) @@ -266,7 +246,7 @@ describe('FSPersistorManagerTests', function() { }) it('Should call stat with correct options', async function() { - await FSPersistorManager.promises.checkIfFileExists(location, files[0]) + await FSPersistor.promises.checkIfFileExists(location, files[0]) expect(fs.stat).to.have.been.calledWith( `${location}/${filteredFilenames[0]}` ) @@ -274,23 +254,18 @@ describe('FSPersistorManagerTests', function() { it('Should return true for existing files', async function() { expect( - await FSPersistorManager.promises.checkIfFileExists(location, files[0]) + await FSPersistor.promises.checkIfFileExists(location, files[0]) ).to.equal(true) }) it('Should return false for non-existing files', async function() { expect( - await FSPersistorManager.promises.checkIfFileExists( - location, - badFilename - ) + await FSPersistor.promises.checkIfFileExists(location, badFilename) ).to.equal(false) }) it('should wrap the error if there is a problem', async function() { - await expect( - FSPersistorManager.promises.checkIfFileExists(location, 'llama') - ) + await expect(FSPersistor.promises.checkIfFileExists(location, 'llama')) .to.eventually.be.rejected.and.be.an.instanceOf(Errors.ReadError) .and.have.property('cause', error) }) @@ -299,9 +274,7 @@ describe('FSPersistorManagerTests', function() { describe('directorySize', function() { it('should wrap the error', async function() { glob.yields(error) - await expect( - FSPersistorManager.promises.directorySize(location, files[0]) - ) + await expect(FSPersistor.promises.directorySize(location, files[0])) .to.eventually.be.rejected.and.be.an.instanceOf(Errors.ReadError) .and.include({ cause: error }) .and.have.property('info') @@ -309,7 +282,7 @@ describe('FSPersistorManagerTests', function() { }) it('should filter the directory name', async function() { - await FSPersistorManager.promises.directorySize(location, files[0]) + await FSPersistor.promises.directorySize(location, files[0]) expect(glob).to.have.been.calledWith( `${location}/${filteredFilenames[0]}_*` ) @@ -317,7 +290,7 @@ describe('FSPersistorManagerTests', function() { it('should sum directory files size', async function() { expect( - await FSPersistorManager.promises.directorySize(location, files[0]) + await FSPersistor.promises.directorySize(location, files[0]) ).to.equal(stat.size * files.length) }) }) diff --git a/services/filestore/test/unit/js/PersistorManagerTests.js b/services/filestore/test/unit/js/PersistorManagerTests.js index 0ecbb22078..cdc9de0f92 100644 --- a/services/filestore/test/unit/js/PersistorManagerTests.js +++ b/services/filestore/test/unit/js/PersistorManagerTests.js @@ -6,18 +6,14 @@ const SandboxedModule = require('sandboxed-module') const modulePath = '../../../app/js/PersistorManager.js' describe('PersistorManager', function() { - let PersistorManager, - FSPersistorManager, - S3PersistorManager, - settings, - requires + let PersistorManager, FSPersistor, S3Persistor, settings, requires beforeEach(function() { - FSPersistorManager = { - wrappedMethod: sinon.stub().returns('FSPersistorManager') + FSPersistor = { + wrappedMethod: sinon.stub().returns('FSPersistor') } - S3PersistorManager = { - wrappedMethod: sinon.stub().returns('S3PersistorManager') + S3Persistor = { + wrappedMethod: sinon.stub().returns('S3Persistor') } settings = { @@ -25,8 +21,8 @@ describe('PersistorManager', function() { } requires = { - './S3PersistorManager': S3PersistorManager, - './FSPersistorManager': FSPersistorManager, + './S3Persistor': S3Persistor, + './FSPersistor': FSPersistor, 'settings-sharelatex': settings, 'logger-sharelatex': { log() {}, @@ -40,7 +36,7 @@ describe('PersistorManager', function() { PersistorManager = SandboxedModule.require(modulePath, { requires }) expect(PersistorManager).to.respondTo('wrappedMethod') - expect(PersistorManager.wrappedMethod()).to.equal('S3PersistorManager') + expect(PersistorManager.wrappedMethod()).to.equal('S3Persistor') }) it("should implement the S3 wrapped method when 'aws-sdk' is configured", function() { @@ -48,7 +44,7 @@ describe('PersistorManager', function() { PersistorManager = SandboxedModule.require(modulePath, { requires }) expect(PersistorManager).to.respondTo('wrappedMethod') - expect(PersistorManager.wrappedMethod()).to.equal('S3PersistorManager') + expect(PersistorManager.wrappedMethod()).to.equal('S3Persistor') }) it('should implement the FS wrapped method when FS is configured', function() { @@ -56,7 +52,7 @@ describe('PersistorManager', function() { PersistorManager = SandboxedModule.require(modulePath, { requires }) expect(PersistorManager).to.respondTo('wrappedMethod') - expect(PersistorManager.wrappedMethod()).to.equal('FSPersistorManager') + expect(PersistorManager.wrappedMethod()).to.equal('FSPersistor') }) it('should throw an error when the backend is not configured', function() { diff --git a/services/filestore/test/unit/js/S3PersistorManagerTests.js b/services/filestore/test/unit/js/S3PersistorTests.js similarity index 87% rename from services/filestore/test/unit/js/S3PersistorManagerTests.js rename to services/filestore/test/unit/js/S3PersistorTests.js index daeac66d3f..7a945b4d19 100644 --- a/services/filestore/test/unit/js/S3PersistorManagerTests.js +++ b/services/filestore/test/unit/js/S3PersistorTests.js @@ -1,12 +1,12 @@ const sinon = require('sinon') const chai = require('chai') const { expect } = chai -const modulePath = '../../../app/js/S3PersistorManager.js' +const modulePath = '../../../app/js/S3Persistor.js' const SandboxedModule = require('sandboxed-module') const Errors = require('../../../app/js/Errors') -describe('S3PersistorManagerTests', function() { +describe('S3PersistorTests', function() { const defaultS3Key = 'frog' const defaultS3Secret = 'prince' const defaultS3Credentials = { @@ -33,7 +33,7 @@ describe('S3PersistorManagerTests', function() { Meter, MeteredStream, ReadStream, - S3PersistorManager, + S3Persistor, S3Client, S3ReadStream, S3NotFoundError, @@ -115,7 +115,7 @@ describe('S3PersistorManagerTests', function() { } S3 = sinon.stub().returns(S3Client) - S3PersistorManager = SandboxedModule.require(modulePath, { + S3Persistor = SandboxedModule.require(modulePath, { requires: { 'aws-sdk/clients/s3': S3, 'settings-sharelatex': settings, @@ -133,7 +133,7 @@ describe('S3PersistorManagerTests', function() { let stream beforeEach(async function() { - stream = await S3PersistorManager.promises.getFileStream(bucket, key) + stream = await S3Persistor.promises.getFileStream(bucket, key) }) it('returns a stream', function() { @@ -164,7 +164,7 @@ describe('S3PersistorManagerTests', function() { let stream beforeEach(async function() { - stream = await S3PersistorManager.promises.getFileStream(bucket, key, { + stream = await S3Persistor.promises.getFileStream(bucket, key, { start: 5, end: 10 }) @@ -201,7 +201,7 @@ describe('S3PersistorManagerTests', function() { auth_secret: alternativeSecret } - stream = await S3PersistorManager.promises.getFileStream(bucket, key) + stream = await S3Persistor.promises.getFileStream(bucket, key) }) it('returns a stream', function() { @@ -220,16 +220,13 @@ describe('S3PersistorManagerTests', function() { }) it('caches the credentials', async function() { - stream = await S3PersistorManager.promises.getFileStream(bucket, key) + stream = await S3Persistor.promises.getFileStream(bucket, key) expect(S3).to.have.been.calledOnceWith(alternativeS3Credentials) }) it('uses the default credentials for an unknown bucket', async function() { - stream = await S3PersistorManager.promises.getFileStream( - 'anotherBucket', - key - ) + stream = await S3Persistor.promises.getFileStream('anotherBucket', key) expect(S3).to.have.been.calledTwice expect(S3.firstCall).to.have.been.calledWith(alternativeS3Credentials) @@ -237,14 +234,8 @@ describe('S3PersistorManagerTests', function() { }) it('caches the default credentials', async function() { - stream = await S3PersistorManager.promises.getFileStream( - 'anotherBucket', - key - ) - stream = await S3PersistorManager.promises.getFileStream( - 'anotherBucket', - key - ) + stream = await S3Persistor.promises.getFileStream('anotherBucket', key) + stream = await S3Persistor.promises.getFileStream('anotherBucket', key) expect(S3).to.have.been.calledTwice expect(S3.firstCall).to.have.been.calledWith(alternativeS3Credentials) @@ -256,7 +247,7 @@ describe('S3PersistorManagerTests', function() { delete settings.filestore.s3.secret await expect( - S3PersistorManager.promises.getFileStream('anotherBucket', key) + S3Persistor.promises.getFileStream('anotherBucket', key) ).to.eventually.be.rejected.and.be.an.instanceOf(Errors.SettingsError) }) }) @@ -268,7 +259,7 @@ describe('S3PersistorManagerTests', function() { S3ReadStream.on = sinon.stub() S3ReadStream.on.withArgs('error').yields(S3NotFoundError) try { - stream = await S3PersistorManager.promises.getFileStream(bucket, key) + stream = await S3Persistor.promises.getFileStream(bucket, key) } catch (err) { error = err } @@ -298,7 +289,7 @@ describe('S3PersistorManagerTests', function() { S3ReadStream.on = sinon.stub() S3ReadStream.on.withArgs('error').yields(S3AccessDeniedError) try { - stream = await S3PersistorManager.promises.getFileStream(bucket, key) + stream = await S3Persistor.promises.getFileStream(bucket, key) } catch (err) { error = err } @@ -328,7 +319,7 @@ describe('S3PersistorManagerTests', function() { S3ReadStream.on = sinon.stub() S3ReadStream.on.withArgs('error').yields(genericError) try { - stream = await S3PersistorManager.promises.getFileStream(bucket, key) + stream = await S3Persistor.promises.getFileStream(bucket, key) } catch (err) { error = err } @@ -357,7 +348,7 @@ describe('S3PersistorManagerTests', function() { let size beforeEach(async function() { - size = await S3PersistorManager.promises.getFileSize(bucket, key) + size = await S3Persistor.promises.getFileSize(bucket, key) }) it('should return the object size', function() { @@ -380,7 +371,7 @@ describe('S3PersistorManagerTests', function() { promise: sinon.stub().rejects(S3NotFoundError) }) try { - await S3PersistorManager.promises.getFileSize(bucket, key) + await S3Persistor.promises.getFileSize(bucket, key) } catch (err) { error = err } @@ -403,7 +394,7 @@ describe('S3PersistorManagerTests', function() { promise: sinon.stub().rejects(genericError) }) try { - await S3PersistorManager.promises.getFileSize(bucket, key) + await S3Persistor.promises.getFileSize(bucket, key) } catch (err) { error = err } @@ -422,7 +413,7 @@ describe('S3PersistorManagerTests', function() { describe('sendStream', function() { describe('with valid parameters', function() { beforeEach(async function() { - return S3PersistorManager.promises.sendStream(bucket, key, ReadStream) + return S3Persistor.promises.sendStream(bucket, key, ReadStream) }) it('should upload the stream', function() { @@ -449,7 +440,7 @@ describe('S3PersistorManagerTests', function() { promise: sinon.stub().rejects(genericError) }) try { - await S3PersistorManager.promises.sendStream(bucket, key, ReadStream) + await S3Persistor.promises.sendStream(bucket, key, ReadStream) } catch (err) { error = err } @@ -464,7 +455,7 @@ describe('S3PersistorManagerTests', function() { describe('sendFile', function() { describe('with valid parameters', function() { beforeEach(async function() { - return S3PersistorManager.promises.sendFile(bucket, key, filename) + return S3Persistor.promises.sendFile(bucket, key, filename) }) it('should create a read stream for the file', function() { @@ -486,7 +477,7 @@ describe('S3PersistorManagerTests', function() { beforeEach(async function() { Fs.createReadStream = sinon.stub().throws(FileNotFoundError) try { - await S3PersistorManager.promises.sendFile(bucket, key, filename) + await S3Persistor.promises.sendFile(bucket, key, filename) } catch (err) { error = err } @@ -507,7 +498,7 @@ describe('S3PersistorManagerTests', function() { beforeEach(async function() { Fs.createReadStream = sinon.stub().throws(genericError) try { - await S3PersistorManager.promises.sendFile(bucket, key, filename) + await S3Persistor.promises.sendFile(bucket, key, filename) } catch (err) { error = err } @@ -526,7 +517,7 @@ describe('S3PersistorManagerTests', function() { describe('copyFile', function() { describe('with valid parameters', function() { beforeEach(async function() { - return S3PersistorManager.promises.copyFile(bucket, key, destKey) + return S3Persistor.promises.copyFile(bucket, key, destKey) }) it('should copy the object', function() { @@ -546,7 +537,7 @@ describe('S3PersistorManagerTests', function() { promise: sinon.stub().rejects(S3NotFoundError) }) try { - await S3PersistorManager.promises.copyFile(bucket, key, destKey) + await S3Persistor.promises.copyFile(bucket, key, destKey) } catch (err) { error = err } @@ -561,7 +552,7 @@ describe('S3PersistorManagerTests', function() { describe('deleteFile', function() { describe('with valid parameters', function() { beforeEach(async function() { - return S3PersistorManager.promises.deleteFile(bucket, key) + return S3Persistor.promises.deleteFile(bucket, key) }) it('should delete the object', function() { @@ -580,7 +571,7 @@ describe('S3PersistorManagerTests', function() { promise: sinon.stub().rejects(S3NotFoundError) }) try { - await S3PersistorManager.promises.deleteFile(bucket, key) + await S3Persistor.promises.deleteFile(bucket, key) } catch (err) { error = err } @@ -595,7 +586,7 @@ describe('S3PersistorManagerTests', function() { describe('deleteDirectory', function() { describe('with valid parameters', function() { beforeEach(async function() { - return S3PersistorManager.promises.deleteDirectory(bucket, key) + return S3Persistor.promises.deleteDirectory(bucket, key) }) it('should list the objects in the directory', function() { @@ -621,7 +612,7 @@ describe('S3PersistorManagerTests', function() { S3Client.listObjects = sinon .stub() .returns({ promise: sinon.stub().resolves({ Contents: [] }) }) - return S3PersistorManager.promises.deleteDirectory(bucket, key) + return S3Persistor.promises.deleteDirectory(bucket, key) }) it('should list the objects in the directory', function() { @@ -644,7 +635,7 @@ describe('S3PersistorManagerTests', function() { .stub() .returns({ promise: sinon.stub().rejects(genericError) }) try { - await S3PersistorManager.promises.deleteDirectory(bucket, key) + await S3Persistor.promises.deleteDirectory(bucket, key) } catch (err) { error = err } @@ -671,7 +662,7 @@ describe('S3PersistorManagerTests', function() { .stub() .returns({ promise: sinon.stub().rejects(genericError) }) try { - await S3PersistorManager.promises.deleteDirectory(bucket, key) + await S3Persistor.promises.deleteDirectory(bucket, key) } catch (err) { error = err } @@ -692,7 +683,7 @@ describe('S3PersistorManagerTests', function() { let size beforeEach(async function() { - size = await S3PersistorManager.promises.directorySize(bucket, key) + size = await S3Persistor.promises.directorySize(bucket, key) }) it('should list the objects in the directory', function() { @@ -714,7 +705,7 @@ describe('S3PersistorManagerTests', function() { S3Client.listObjects = sinon .stub() .returns({ promise: sinon.stub().resolves({ Contents: [] }) }) - size = await S3PersistorManager.promises.directorySize(bucket, key) + size = await S3Persistor.promises.directorySize(bucket, key) }) it('should list the objects in the directory', function() { @@ -737,7 +728,7 @@ describe('S3PersistorManagerTests', function() { .stub() .returns({ promise: sinon.stub().rejects(genericError) }) try { - await S3PersistorManager.promises.directorySize(bucket, key) + await S3Persistor.promises.directorySize(bucket, key) } catch (err) { error = err } @@ -758,10 +749,7 @@ describe('S3PersistorManagerTests', function() { let exists beforeEach(async function() { - exists = await S3PersistorManager.promises.checkIfFileExists( - bucket, - key - ) + exists = await S3Persistor.promises.checkIfFileExists(bucket, key) }) it('should get the object header', function() { @@ -783,10 +771,7 @@ describe('S3PersistorManagerTests', function() { S3Client.headObject = sinon .stub() .returns({ promise: sinon.stub().rejects(S3NotFoundError) }) - exists = await S3PersistorManager.promises.checkIfFileExists( - bucket, - key - ) + exists = await S3Persistor.promises.checkIfFileExists(bucket, key) }) it('should get the object header', function() { @@ -809,7 +794,7 @@ describe('S3PersistorManagerTests', function() { .stub() .returns({ promise: sinon.stub().rejects(genericError) }) try { - await S3PersistorManager.promises.checkIfFileExists(bucket, key) + await S3Persistor.promises.checkIfFileExists(bucket, key) } catch (err) { error = err }