Automatically clear CLSI cache when compile fails
This commit is contained in:
@@ -72,6 +72,19 @@ describe "ClsiManager", ->
|
||||
it "should call the callback with a failure statue", ->
|
||||
@callback.calledWith(null, @status).should.equal true
|
||||
|
||||
describe "deleteAuxFiles", ->
|
||||
beforeEach ->
|
||||
@request.del = sinon.stub().callsArg(1)
|
||||
@ClsiManager.deleteAuxFiles @project_id, @callback
|
||||
|
||||
it "should call the delete method in the CLSI", ->
|
||||
@request.del
|
||||
.calledWith("#{@settings.apis.clsi.url}/project/#{@project_id}")
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
describe "_buildRequest", ->
|
||||
beforeEach ->
|
||||
@project =
|
||||
|
||||
@@ -21,6 +21,7 @@ describe "CompileController", ->
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"../../infrastructure/Metrics": @Metrics = { inc: sinon.stub() }
|
||||
"./CompileManager":@CompileManager
|
||||
"./ClsiManager": @ClsiManager
|
||||
"../Authentication/AuthenticationController": @AuthenticationController = {}
|
||||
@project_id = "project-id"
|
||||
@next = sinon.stub()
|
||||
@@ -144,14 +145,20 @@ describe "CompileController", ->
|
||||
|
||||
describe "deleteAuxFiles", ->
|
||||
beforeEach ->
|
||||
@CompileController.proxyToClsi = sinon.stub()
|
||||
@ClsiManager.deleteAuxFiles = sinon.stub().callsArg(1)
|
||||
@req.params =
|
||||
Project_id: @project_id
|
||||
@res.send = sinon.stub()
|
||||
@CompileController.deleteAuxFiles @req, @res, @next
|
||||
|
||||
it "should proxy to the CLSI", ->
|
||||
@CompileController.proxyToClsi
|
||||
.calledWith("/project/#{@project_id}", @req, @res, @next)
|
||||
@ClsiManager.deleteAuxFiles
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
it "should return a 200", ->
|
||||
@res.send
|
||||
.calledWith(200)
|
||||
.should.equal true
|
||||
|
||||
describe "compileAndDownloadPdf", ->
|
||||
|
||||
@@ -75,6 +75,23 @@ describe "CompileManager", ->
|
||||
@logger.log
|
||||
.calledWith(project_id: @project_id, user_id: @user_id, "compiling project")
|
||||
.should.equal true
|
||||
|
||||
describe "when the compile fails", ->
|
||||
beforeEach ->
|
||||
@CompileManager._checkIfAutoCompileLimitHasBeenHit = (_, cb)-> cb(null, true)
|
||||
@ClsiManager.deleteAuxFiles = sinon.stub()
|
||||
@ClsiManager.sendRequest = sinon.stub().callsArgWith(1, null, @status = "failure")
|
||||
@CompileManager.compile @project_id, @user_id, {}, @callback
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback
|
||||
.calledWith(null, @status)
|
||||
.should.equal true
|
||||
|
||||
it "should clear the CLSI cache", ->
|
||||
@ClsiManager.deleteAuxFiles
|
||||
.calledWith(@project_id)
|
||||
.should.equal true
|
||||
|
||||
describe "when the project has been recently compiled", ->
|
||||
beforeEach ->
|
||||
|
||||
Reference in New Issue
Block a user