Ver código fonte

Rename *PersistorManager to *Persistor

Simon Detheridge 6 anos atrás
pai
commit
f877f51775

+ 0 - 0
services/filestore/app/js/FSPersistorManager.js → services/filestore/app/js/FSPersistor.js


+ 2 - 2
services/filestore/app/js/PersistorManager.js

@@ -14,10 +14,10 @@ if (!settings.filestore.backend) {
 switch (settings.filestore.backend) {
 switch (settings.filestore.backend) {
   case 'aws-sdk':
   case 'aws-sdk':
   case 's3':
   case 's3':
-    module.exports = require('./S3PersistorManager')
+    module.exports = require('./S3Persistor')
     break
     break
   case 'fs':
   case 'fs':
-    module.exports = require('./FSPersistorManager')
+    module.exports = require('./FSPersistor')
     break
     break
   default:
   default:
     throw new Error(`unknown filestore backend: ${settings.filestore.backend}`)
     throw new Error(`unknown filestore backend: ${settings.filestore.backend}`)

+ 0 - 0
services/filestore/app/js/S3PersistorManager.js → services/filestore/app/js/S3Persistor.js


+ 31 - 58
services/filestore/test/unit/js/FSPersistorManagerTests.js → 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('sinon-chai'))
 chai.use(require('chai-as-promised'))
 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 stat = { size: 4, isFile: sinon.stub().returns(true) }
   const fd = 1234
   const fd = 1234
   const readStream = 'readStream'
   const readStream = 'readStream'
@@ -22,7 +22,7 @@ describe('FSPersistorManagerTests', function() {
   const files = ['animals/wombat.tex', 'vegetables/potato.tex']
   const files = ['animals/wombat.tex', 'vegetables/potato.tex']
   const globs = [`${location}/${files[0]}`, `${location}/${files[1]}`]
   const globs = [`${location}/${files[0]}`, `${location}/${files[1]}`]
   const filteredFilenames = ['animals_wombat.tex', 'vegetables_potato.tex']
   const filteredFilenames = ['animals_wombat.tex', 'vegetables_potato.tex']
-  let fs, rimraf, stream, LocalFileWriter, FSPersistorManager, glob
+  let fs, rimraf, stream, LocalFileWriter, FSPersistor, glob
 
 
   beforeEach(function() {
   beforeEach(function() {
     fs = {
     fs = {
@@ -41,7 +41,7 @@ describe('FSPersistorManagerTests', function() {
         deleteFile: sinon.stub().resolves()
         deleteFile: sinon.stub().resolves()
       }
       }
     }
     }
-    FSPersistorManager = SandboxedModule.require(modulePath, {
+    FSPersistor = SandboxedModule.require(modulePath, {
       requires: {
       requires: {
         './LocalFileWriter': LocalFileWriter,
         './LocalFileWriter': LocalFileWriter,
         './Errors': Errors,
         './Errors': Errors,
@@ -57,7 +57,7 @@ describe('FSPersistorManagerTests', function() {
   describe('sendFile', function() {
   describe('sendFile', function() {
     const localFilesystemPath = '/path/to/local/file'
     const localFilesystemPath = '/path/to/local/file'
     it('should copy the file', async function() {
     it('should copy the file', async function() {
-      await FSPersistorManager.promises.sendFile(
+      await FSPersistor.promises.sendFile(
         location,
         location,
         files[0],
         files[0],
         localFilesystemPath
         localFilesystemPath
@@ -72,33 +72,21 @@ describe('FSPersistorManagerTests', function() {
     it('should return an error if the file cannot be stored', async function() {
     it('should return an error if the file cannot be stored', async function() {
       stream.pipeline.yields(error)
       stream.pipeline.yields(error)
       await expect(
       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)
       ).to.eventually.be.rejected.and.have.property('cause', error)
     })
     })
   })
   })
 
 
   describe('sendStream', function() {
   describe('sendStream', function() {
     it('should send the stream to LocalFileWriter', async 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(
       expect(LocalFileWriter.promises.writeStream).to.have.been.calledWith(
         remoteStream
         remoteStream
       )
       )
     })
     })
 
 
     it('should delete the temporary file', async function() {
     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(
       expect(LocalFileWriter.promises.deleteFile).to.have.been.calledWith(
         tempFile
         tempFile
       )
       )
@@ -107,30 +95,26 @@ describe('FSPersistorManagerTests', function() {
     it('should return the error from LocalFileWriter', async function() {
     it('should return the error from LocalFileWriter', async function() {
       LocalFileWriter.promises.writeStream.rejects(error)
       LocalFileWriter.promises.writeStream.rejects(error)
       await expect(
       await expect(
-        FSPersistorManager.promises.sendStream(location, files[0], remoteStream)
+        FSPersistor.promises.sendStream(location, files[0], remoteStream)
       ).to.eventually.be.rejectedWith(error)
       ).to.eventually.be.rejectedWith(error)
     })
     })
 
 
     it('should send the temporary file to the filestore', async function() {
     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)
       expect(fs.createReadStream).to.have.been.calledWith(tempFile)
     })
     })
   })
   })
 
 
   describe('getFileStream', function() {
   describe('getFileStream', function() {
     it('should use correct file location', async 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(
       expect(fs.open).to.have.been.calledWith(
         `${location}/${filteredFilenames[0]}`
         `${location}/${filteredFilenames[0]}`
       )
       )
     })
     })
 
 
     it('should pass the options to createReadStream', async function() {
     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,
         start: 0,
         end: 8
         end: 8
       })
       })
@@ -146,18 +130,14 @@ describe('FSPersistorManagerTests', function() {
       err.code = 'ENOENT'
       err.code = 'ENOENT'
       fs.open.yields(err)
       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)
         .to.eventually.be.rejected.and.be.an.instanceOf(Errors.NotFoundError)
         .and.have.property('cause', err)
         .and.have.property('cause', err)
     })
     })
 
 
     it('should wrap any other error', async function() {
     it('should wrap any other error', async function() {
       fs.open.yields(error)
       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')
         .to.eventually.be.rejectedWith('failed to open file for streaming')
         .and.be.an.instanceOf(Errors.ReadError)
         .and.be.an.instanceOf(Errors.ReadError)
         .and.have.property('cause', error)
         .and.have.property('cause', error)
@@ -181,18 +161,18 @@ describe('FSPersistorManagerTests', function() {
 
 
     it('should return the file size', async function() {
     it('should return the file size', async function() {
       expect(
       expect(
-        await FSPersistorManager.promises.getFileSize(location, files[0])
+        await FSPersistor.promises.getFileSize(location, files[0])
       ).to.equal(size)
       ).to.equal(size)
     })
     })
 
 
     it('should throw a NotFoundError if the file does not exist', async function() {
     it('should throw a NotFoundError if the file does not exist', async function() {
       await expect(
       await expect(
-        FSPersistorManager.promises.getFileSize(location, badFilename)
+        FSPersistor.promises.getFileSize(location, badFilename)
       ).to.eventually.be.rejected.and.be.an.instanceOf(Errors.NotFoundError)
       ).to.eventually.be.rejected.and.be.an.instanceOf(Errors.NotFoundError)
     })
     })
 
 
     it('should wrap any other error', async function() {
     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)
         .to.eventually.be.rejected.and.be.an.instanceOf(Errors.ReadError)
         .and.have.property('cause', error)
         .and.have.property('cause', error)
     })
     })
@@ -200,28 +180,28 @@ describe('FSPersistorManagerTests', function() {
 
 
   describe('copyFile', function() {
   describe('copyFile', function() {
     it('Should open the source for reading', async 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(
       expect(fs.createReadStream).to.have.been.calledWith(
         `${location}/${filteredFilenames[0]}`
         `${location}/${filteredFilenames[0]}`
       )
       )
     })
     })
 
 
     it('Should open the target for writing', async function() {
     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(
       expect(fs.createWriteStream).to.have.been.calledWith(
         `${location}/${filteredFilenames[1]}`
         `${location}/${filteredFilenames[1]}`
       )
       )
     })
     })
 
 
     it('Should pipe the source to the target', async function() {
     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)
       expect(stream.pipeline).to.have.been.calledWith(readStream, writeStream)
     })
     })
   })
   })
 
 
   describe('deleteFile', function() {
   describe('deleteFile', function() {
     it('Should call unlink with correct options', async 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(
       expect(fs.unlink).to.have.been.calledWith(
         `${location}/${filteredFilenames[0]}`
         `${location}/${filteredFilenames[0]}`
       )
       )
@@ -230,14 +210,14 @@ describe('FSPersistorManagerTests', function() {
     it('Should propagate the error', async function() {
     it('Should propagate the error', async function() {
       fs.unlink.yields(error)
       fs.unlink.yields(error)
       await expect(
       await expect(
-        FSPersistorManager.promises.deleteFile(location, files[0])
+        FSPersistor.promises.deleteFile(location, files[0])
       ).to.eventually.be.rejected.and.have.property('cause', error)
       ).to.eventually.be.rejected.and.have.property('cause', error)
     })
     })
   })
   })
 
 
   describe('deleteDirectory', function() {
   describe('deleteDirectory', function() {
     it('Should call rmdir(rimraf) with correct options', async 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(
       expect(rimraf).to.have.been.calledWith(
         `${location}/${filteredFilenames[0]}`
         `${location}/${filteredFilenames[0]}`
       )
       )
@@ -246,7 +226,7 @@ describe('FSPersistorManagerTests', function() {
     it('Should propagate the error', async function() {
     it('Should propagate the error', async function() {
       rimraf.yields(error)
       rimraf.yields(error)
       await expect(
       await expect(
-        FSPersistorManager.promises.deleteDirectory(location, files[0])
+        FSPersistor.promises.deleteDirectory(location, files[0])
       ).to.eventually.be.rejected.and.have.property('cause', error)
       ).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() {
     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(
       expect(fs.stat).to.have.been.calledWith(
         `${location}/${filteredFilenames[0]}`
         `${location}/${filteredFilenames[0]}`
       )
       )
@@ -274,23 +254,18 @@ describe('FSPersistorManagerTests', function() {
 
 
     it('Should return true for existing files', async function() {
     it('Should return true for existing files', async function() {
       expect(
       expect(
-        await FSPersistorManager.promises.checkIfFileExists(location, files[0])
+        await FSPersistor.promises.checkIfFileExists(location, files[0])
       ).to.equal(true)
       ).to.equal(true)
     })
     })
 
 
     it('Should return false for non-existing files', async function() {
     it('Should return false for non-existing files', async function() {
       expect(
       expect(
-        await FSPersistorManager.promises.checkIfFileExists(
-          location,
-          badFilename
-        )
+        await FSPersistor.promises.checkIfFileExists(location, badFilename)
       ).to.equal(false)
       ).to.equal(false)
     })
     })
 
 
     it('should wrap the error if there is a problem', async function() {
     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)
         .to.eventually.be.rejected.and.be.an.instanceOf(Errors.ReadError)
         .and.have.property('cause', error)
         .and.have.property('cause', error)
     })
     })
@@ -299,9 +274,7 @@ describe('FSPersistorManagerTests', function() {
   describe('directorySize', function() {
   describe('directorySize', function() {
     it('should wrap the error', async function() {
     it('should wrap the error', async function() {
       glob.yields(error)
       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)
         .to.eventually.be.rejected.and.be.an.instanceOf(Errors.ReadError)
         .and.include({ cause: error })
         .and.include({ cause: error })
         .and.have.property('info')
         .and.have.property('info')
@@ -309,7 +282,7 @@ describe('FSPersistorManagerTests', function() {
     })
     })
 
 
     it('should filter the directory name', async 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(
       expect(glob).to.have.been.calledWith(
         `${location}/${filteredFilenames[0]}_*`
         `${location}/${filteredFilenames[0]}_*`
       )
       )
@@ -317,7 +290,7 @@ describe('FSPersistorManagerTests', function() {
 
 
     it('should sum directory files size', async function() {
     it('should sum directory files size', async function() {
       expect(
       expect(
-        await FSPersistorManager.promises.directorySize(location, files[0])
+        await FSPersistor.promises.directorySize(location, files[0])
       ).to.equal(stat.size * files.length)
       ).to.equal(stat.size * files.length)
     })
     })
   })
   })

+ 10 - 14
services/filestore/test/unit/js/PersistorManagerTests.js

@@ -6,18 +6,14 @@ const SandboxedModule = require('sandboxed-module')
 const modulePath = '../../../app/js/PersistorManager.js'
 const modulePath = '../../../app/js/PersistorManager.js'
 
 
 describe('PersistorManager', function() {
 describe('PersistorManager', function() {
-  let PersistorManager,
-    FSPersistorManager,
-    S3PersistorManager,
-    settings,
-    requires
+  let PersistorManager, FSPersistor, S3Persistor, settings, requires
 
 
   beforeEach(function() {
   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 = {
     settings = {
@@ -25,8 +21,8 @@ describe('PersistorManager', function() {
     }
     }
 
 
     requires = {
     requires = {
-      './S3PersistorManager': S3PersistorManager,
-      './FSPersistorManager': FSPersistorManager,
+      './S3Persistor': S3Persistor,
+      './FSPersistor': FSPersistor,
       'settings-sharelatex': settings,
       'settings-sharelatex': settings,
       'logger-sharelatex': {
       'logger-sharelatex': {
         log() {},
         log() {},
@@ -40,7 +36,7 @@ describe('PersistorManager', function() {
     PersistorManager = SandboxedModule.require(modulePath, { requires })
     PersistorManager = SandboxedModule.require(modulePath, { requires })
 
 
     expect(PersistorManager).to.respondTo('wrappedMethod')
     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() {
   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 })
     PersistorManager = SandboxedModule.require(modulePath, { requires })
 
 
     expect(PersistorManager).to.respondTo('wrappedMethod')
     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() {
   it('should implement the FS wrapped method when FS is configured', function() {
@@ -56,7 +52,7 @@ describe('PersistorManager', function() {
     PersistorManager = SandboxedModule.require(modulePath, { requires })
     PersistorManager = SandboxedModule.require(modulePath, { requires })
 
 
     expect(PersistorManager).to.respondTo('wrappedMethod')
     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() {
   it('should throw an error when the backend is not configured', function() {

+ 37 - 52
services/filestore/test/unit/js/S3PersistorManagerTests.js → services/filestore/test/unit/js/S3PersistorTests.js

@@ -1,12 +1,12 @@
 const sinon = require('sinon')
 const sinon = require('sinon')
 const chai = require('chai')
 const chai = require('chai')
 const { expect } = chai
 const { expect } = chai
-const modulePath = '../../../app/js/S3PersistorManager.js'
+const modulePath = '../../../app/js/S3Persistor.js'
 const SandboxedModule = require('sandboxed-module')
 const SandboxedModule = require('sandboxed-module')
 
 
 const Errors = require('../../../app/js/Errors')
 const Errors = require('../../../app/js/Errors')
 
 
-describe('S3PersistorManagerTests', function() {
+describe('S3PersistorTests', function() {
   const defaultS3Key = 'frog'
   const defaultS3Key = 'frog'
   const defaultS3Secret = 'prince'
   const defaultS3Secret = 'prince'
   const defaultS3Credentials = {
   const defaultS3Credentials = {
@@ -33,7 +33,7 @@ describe('S3PersistorManagerTests', function() {
     Meter,
     Meter,
     MeteredStream,
     MeteredStream,
     ReadStream,
     ReadStream,
-    S3PersistorManager,
+    S3Persistor,
     S3Client,
     S3Client,
     S3ReadStream,
     S3ReadStream,
     S3NotFoundError,
     S3NotFoundError,
@@ -115,7 +115,7 @@ describe('S3PersistorManagerTests', function() {
     }
     }
     S3 = sinon.stub().returns(S3Client)
     S3 = sinon.stub().returns(S3Client)
 
 
-    S3PersistorManager = SandboxedModule.require(modulePath, {
+    S3Persistor = SandboxedModule.require(modulePath, {
       requires: {
       requires: {
         'aws-sdk/clients/s3': S3,
         'aws-sdk/clients/s3': S3,
         'settings-sharelatex': settings,
         'settings-sharelatex': settings,
@@ -133,7 +133,7 @@ describe('S3PersistorManagerTests', function() {
       let stream
       let stream
 
 
       beforeEach(async function() {
       beforeEach(async function() {
-        stream = await S3PersistorManager.promises.getFileStream(bucket, key)
+        stream = await S3Persistor.promises.getFileStream(bucket, key)
       })
       })
 
 
       it('returns a stream', function() {
       it('returns a stream', function() {
@@ -164,7 +164,7 @@ describe('S3PersistorManagerTests', function() {
       let stream
       let stream
 
 
       beforeEach(async function() {
       beforeEach(async function() {
-        stream = await S3PersistorManager.promises.getFileStream(bucket, key, {
+        stream = await S3Persistor.promises.getFileStream(bucket, key, {
           start: 5,
           start: 5,
           end: 10
           end: 10
         })
         })
@@ -201,7 +201,7 @@ describe('S3PersistorManagerTests', function() {
           auth_secret: alternativeSecret
           auth_secret: alternativeSecret
         }
         }
 
 
-        stream = await S3PersistorManager.promises.getFileStream(bucket, key)
+        stream = await S3Persistor.promises.getFileStream(bucket, key)
       })
       })
 
 
       it('returns a stream', function() {
       it('returns a stream', function() {
@@ -220,16 +220,13 @@ describe('S3PersistorManagerTests', function() {
       })
       })
 
 
       it('caches the credentials', async 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)
         expect(S3).to.have.been.calledOnceWith(alternativeS3Credentials)
       })
       })
 
 
       it('uses the default credentials for an unknown bucket', async function() {
       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).to.have.been.calledTwice
         expect(S3.firstCall).to.have.been.calledWith(alternativeS3Credentials)
         expect(S3.firstCall).to.have.been.calledWith(alternativeS3Credentials)
@@ -237,14 +234,8 @@ describe('S3PersistorManagerTests', function() {
       })
       })
 
 
       it('caches the default credentials', async 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).to.have.been.calledTwice
         expect(S3.firstCall).to.have.been.calledWith(alternativeS3Credentials)
         expect(S3.firstCall).to.have.been.calledWith(alternativeS3Credentials)
@@ -256,7 +247,7 @@ describe('S3PersistorManagerTests', function() {
         delete settings.filestore.s3.secret
         delete settings.filestore.s3.secret
 
 
         await expect(
         await expect(
-          S3PersistorManager.promises.getFileStream('anotherBucket', key)
+          S3Persistor.promises.getFileStream('anotherBucket', key)
         ).to.eventually.be.rejected.and.be.an.instanceOf(Errors.SettingsError)
         ).to.eventually.be.rejected.and.be.an.instanceOf(Errors.SettingsError)
       })
       })
     })
     })
@@ -268,7 +259,7 @@ describe('S3PersistorManagerTests', function() {
         S3ReadStream.on = sinon.stub()
         S3ReadStream.on = sinon.stub()
         S3ReadStream.on.withArgs('error').yields(S3NotFoundError)
         S3ReadStream.on.withArgs('error').yields(S3NotFoundError)
         try {
         try {
-          stream = await S3PersistorManager.promises.getFileStream(bucket, key)
+          stream = await S3Persistor.promises.getFileStream(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -298,7 +289,7 @@ describe('S3PersistorManagerTests', function() {
         S3ReadStream.on = sinon.stub()
         S3ReadStream.on = sinon.stub()
         S3ReadStream.on.withArgs('error').yields(S3AccessDeniedError)
         S3ReadStream.on.withArgs('error').yields(S3AccessDeniedError)
         try {
         try {
-          stream = await S3PersistorManager.promises.getFileStream(bucket, key)
+          stream = await S3Persistor.promises.getFileStream(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -328,7 +319,7 @@ describe('S3PersistorManagerTests', function() {
         S3ReadStream.on = sinon.stub()
         S3ReadStream.on = sinon.stub()
         S3ReadStream.on.withArgs('error').yields(genericError)
         S3ReadStream.on.withArgs('error').yields(genericError)
         try {
         try {
-          stream = await S3PersistorManager.promises.getFileStream(bucket, key)
+          stream = await S3Persistor.promises.getFileStream(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -357,7 +348,7 @@ describe('S3PersistorManagerTests', function() {
       let size
       let size
 
 
       beforeEach(async function() {
       beforeEach(async function() {
-        size = await S3PersistorManager.promises.getFileSize(bucket, key)
+        size = await S3Persistor.promises.getFileSize(bucket, key)
       })
       })
 
 
       it('should return the object size', function() {
       it('should return the object size', function() {
@@ -380,7 +371,7 @@ describe('S3PersistorManagerTests', function() {
           promise: sinon.stub().rejects(S3NotFoundError)
           promise: sinon.stub().rejects(S3NotFoundError)
         })
         })
         try {
         try {
-          await S3PersistorManager.promises.getFileSize(bucket, key)
+          await S3Persistor.promises.getFileSize(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -403,7 +394,7 @@ describe('S3PersistorManagerTests', function() {
           promise: sinon.stub().rejects(genericError)
           promise: sinon.stub().rejects(genericError)
         })
         })
         try {
         try {
-          await S3PersistorManager.promises.getFileSize(bucket, key)
+          await S3Persistor.promises.getFileSize(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -422,7 +413,7 @@ describe('S3PersistorManagerTests', function() {
   describe('sendStream', function() {
   describe('sendStream', function() {
     describe('with valid parameters', function() {
     describe('with valid parameters', function() {
       beforeEach(async function() {
       beforeEach(async function() {
-        return S3PersistorManager.promises.sendStream(bucket, key, ReadStream)
+        return S3Persistor.promises.sendStream(bucket, key, ReadStream)
       })
       })
 
 
       it('should upload the stream', function() {
       it('should upload the stream', function() {
@@ -449,7 +440,7 @@ describe('S3PersistorManagerTests', function() {
           promise: sinon.stub().rejects(genericError)
           promise: sinon.stub().rejects(genericError)
         })
         })
         try {
         try {
-          await S3PersistorManager.promises.sendStream(bucket, key, ReadStream)
+          await S3Persistor.promises.sendStream(bucket, key, ReadStream)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -464,7 +455,7 @@ describe('S3PersistorManagerTests', function() {
   describe('sendFile', function() {
   describe('sendFile', function() {
     describe('with valid parameters', function() {
     describe('with valid parameters', function() {
       beforeEach(async 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() {
       it('should create a read stream for the file', function() {
@@ -486,7 +477,7 @@ describe('S3PersistorManagerTests', function() {
       beforeEach(async function() {
       beforeEach(async function() {
         Fs.createReadStream = sinon.stub().throws(FileNotFoundError)
         Fs.createReadStream = sinon.stub().throws(FileNotFoundError)
         try {
         try {
-          await S3PersistorManager.promises.sendFile(bucket, key, filename)
+          await S3Persistor.promises.sendFile(bucket, key, filename)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -507,7 +498,7 @@ describe('S3PersistorManagerTests', function() {
       beforeEach(async function() {
       beforeEach(async function() {
         Fs.createReadStream = sinon.stub().throws(genericError)
         Fs.createReadStream = sinon.stub().throws(genericError)
         try {
         try {
-          await S3PersistorManager.promises.sendFile(bucket, key, filename)
+          await S3Persistor.promises.sendFile(bucket, key, filename)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -526,7 +517,7 @@ describe('S3PersistorManagerTests', function() {
   describe('copyFile', function() {
   describe('copyFile', function() {
     describe('with valid parameters', function() {
     describe('with valid parameters', function() {
       beforeEach(async function() {
       beforeEach(async function() {
-        return S3PersistorManager.promises.copyFile(bucket, key, destKey)
+        return S3Persistor.promises.copyFile(bucket, key, destKey)
       })
       })
 
 
       it('should copy the object', function() {
       it('should copy the object', function() {
@@ -546,7 +537,7 @@ describe('S3PersistorManagerTests', function() {
           promise: sinon.stub().rejects(S3NotFoundError)
           promise: sinon.stub().rejects(S3NotFoundError)
         })
         })
         try {
         try {
-          await S3PersistorManager.promises.copyFile(bucket, key, destKey)
+          await S3Persistor.promises.copyFile(bucket, key, destKey)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -561,7 +552,7 @@ describe('S3PersistorManagerTests', function() {
   describe('deleteFile', function() {
   describe('deleteFile', function() {
     describe('with valid parameters', function() {
     describe('with valid parameters', function() {
       beforeEach(async function() {
       beforeEach(async function() {
-        return S3PersistorManager.promises.deleteFile(bucket, key)
+        return S3Persistor.promises.deleteFile(bucket, key)
       })
       })
 
 
       it('should delete the object', function() {
       it('should delete the object', function() {
@@ -580,7 +571,7 @@ describe('S3PersistorManagerTests', function() {
           promise: sinon.stub().rejects(S3NotFoundError)
           promise: sinon.stub().rejects(S3NotFoundError)
         })
         })
         try {
         try {
-          await S3PersistorManager.promises.deleteFile(bucket, key)
+          await S3Persistor.promises.deleteFile(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -595,7 +586,7 @@ describe('S3PersistorManagerTests', function() {
   describe('deleteDirectory', function() {
   describe('deleteDirectory', function() {
     describe('with valid parameters', function() {
     describe('with valid parameters', function() {
       beforeEach(async 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() {
       it('should list the objects in the directory', function() {
@@ -621,7 +612,7 @@ describe('S3PersistorManagerTests', function() {
         S3Client.listObjects = sinon
         S3Client.listObjects = sinon
           .stub()
           .stub()
           .returns({ promise: sinon.stub().resolves({ Contents: [] }) })
           .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() {
       it('should list the objects in the directory', function() {
@@ -644,7 +635,7 @@ describe('S3PersistorManagerTests', function() {
           .stub()
           .stub()
           .returns({ promise: sinon.stub().rejects(genericError) })
           .returns({ promise: sinon.stub().rejects(genericError) })
         try {
         try {
-          await S3PersistorManager.promises.deleteDirectory(bucket, key)
+          await S3Persistor.promises.deleteDirectory(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -671,7 +662,7 @@ describe('S3PersistorManagerTests', function() {
           .stub()
           .stub()
           .returns({ promise: sinon.stub().rejects(genericError) })
           .returns({ promise: sinon.stub().rejects(genericError) })
         try {
         try {
-          await S3PersistorManager.promises.deleteDirectory(bucket, key)
+          await S3Persistor.promises.deleteDirectory(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -692,7 +683,7 @@ describe('S3PersistorManagerTests', function() {
       let size
       let size
 
 
       beforeEach(async function() {
       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() {
       it('should list the objects in the directory', function() {
@@ -714,7 +705,7 @@ describe('S3PersistorManagerTests', function() {
         S3Client.listObjects = sinon
         S3Client.listObjects = sinon
           .stub()
           .stub()
           .returns({ promise: sinon.stub().resolves({ Contents: [] }) })
           .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() {
       it('should list the objects in the directory', function() {
@@ -737,7 +728,7 @@ describe('S3PersistorManagerTests', function() {
           .stub()
           .stub()
           .returns({ promise: sinon.stub().rejects(genericError) })
           .returns({ promise: sinon.stub().rejects(genericError) })
         try {
         try {
-          await S3PersistorManager.promises.directorySize(bucket, key)
+          await S3Persistor.promises.directorySize(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }
@@ -758,10 +749,7 @@ describe('S3PersistorManagerTests', function() {
       let exists
       let exists
 
 
       beforeEach(async function() {
       beforeEach(async function() {
-        exists = await S3PersistorManager.promises.checkIfFileExists(
-          bucket,
-          key
-        )
+        exists = await S3Persistor.promises.checkIfFileExists(bucket, key)
       })
       })
 
 
       it('should get the object header', function() {
       it('should get the object header', function() {
@@ -783,10 +771,7 @@ describe('S3PersistorManagerTests', function() {
         S3Client.headObject = sinon
         S3Client.headObject = sinon
           .stub()
           .stub()
           .returns({ promise: sinon.stub().rejects(S3NotFoundError) })
           .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() {
       it('should get the object header', function() {
@@ -809,7 +794,7 @@ describe('S3PersistorManagerTests', function() {
           .stub()
           .stub()
           .returns({ promise: sinon.stub().rejects(genericError) })
           .returns({ promise: sinon.stub().rejects(genericError) })
         try {
         try {
-          await S3PersistorManager.promises.checkIfFileExists(bucket, key)
+          await S3Persistor.promises.checkIfFileExists(bucket, key)
         } catch (err) {
         } catch (err) {
           error = err
           error = err
         }
         }