add per-user routes for clearing cache and extend expiry methods
this adds separate functionality for clearing the cache (assets and database) and the project compile directory for a specific user
This commit is contained in:
@@ -105,12 +105,12 @@ describe "CompileManager", ->
|
||||
@proc.stdout = new EventEmitter()
|
||||
@proc.stderr = new EventEmitter()
|
||||
@child_process.spawn = sinon.stub().returns(@proc)
|
||||
@CompileManager.clearProject @project_id, @callback
|
||||
@CompileManager.clearProject @project_id, @user_id, @callback
|
||||
@proc.emit "close", 0
|
||||
|
||||
it "should remove the project directory", ->
|
||||
@child_process.spawn
|
||||
.calledWith("rm", ["-r", "#{@Settings.path.compilesDir}/#{@project_id}"])
|
||||
.calledWith("rm", ["-r", "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}"])
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
@@ -124,13 +124,13 @@ describe "CompileManager", ->
|
||||
@proc.stdout = new EventEmitter()
|
||||
@proc.stderr = new EventEmitter()
|
||||
@child_process.spawn = sinon.stub().returns(@proc)
|
||||
@CompileManager.clearProject @project_id, @callback
|
||||
@CompileManager.clearProject @project_id, @user_id, @callback
|
||||
@proc.stderr.emit "data", @error = "oops"
|
||||
@proc.emit "close", 1
|
||||
|
||||
it "should remove the project directory", ->
|
||||
@child_process.spawn
|
||||
.calledWith("rm", ["-r", "#{@Settings.path.compilesDir}/#{@project_id}"])
|
||||
.calledWith("rm", ["-r", "#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}"])
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback with an error from the stderr", ->
|
||||
@@ -138,7 +138,7 @@ describe "CompileManager", ->
|
||||
.calledWith(new Error())
|
||||
.should.equal true
|
||||
|
||||
@callback.args[0][0].message.should.equal "rm -r #{@Settings.path.compilesDir}/#{@project_id} failed: #{@error}"
|
||||
@callback.args[0][0].message.should.equal "rm -r #{@Settings.path.compilesDir}/#{@project_id}-#{@user_id} failed: #{@error}"
|
||||
|
||||
describe "syncing", ->
|
||||
beforeEach ->
|
||||
|
||||
@@ -13,6 +13,7 @@ describe "ProjectPersistenceManager", ->
|
||||
"./db": @db = {}
|
||||
@callback = sinon.stub()
|
||||
@project_id = "project-id-123"
|
||||
@user_id = "1234"
|
||||
|
||||
describe "clearExpiredProjects", ->
|
||||
beforeEach ->
|
||||
@@ -21,12 +22,13 @@ describe "ProjectPersistenceManager", ->
|
||||
"project-id-2"
|
||||
]
|
||||
@ProjectPersistenceManager._findExpiredProjectIds = sinon.stub().callsArgWith(0, null, @project_ids)
|
||||
@ProjectPersistenceManager.clearProject = sinon.stub().callsArg(1)
|
||||
@ProjectPersistenceManager.clearProjectFromCache = sinon.stub().callsArg(1)
|
||||
@CompileManager.clearExpiredProjects = sinon.stub().callsArg(1)
|
||||
@ProjectPersistenceManager.clearExpiredProjects @callback
|
||||
|
||||
it "should clear each expired project", ->
|
||||
for project_id in @project_ids
|
||||
@ProjectPersistenceManager.clearProject
|
||||
@ProjectPersistenceManager.clearProjectFromCache
|
||||
.calledWith(project_id)
|
||||
.should.equal true
|
||||
|
||||
@@ -37,8 +39,8 @@ describe "ProjectPersistenceManager", ->
|
||||
beforeEach ->
|
||||
@ProjectPersistenceManager._clearProjectFromDatabase = sinon.stub().callsArg(1)
|
||||
@UrlCache.clearProject = sinon.stub().callsArg(1)
|
||||
@CompileManager.clearProject = sinon.stub().callsArg(1)
|
||||
@ProjectPersistenceManager.clearProject @project_id, @callback
|
||||
@CompileManager.clearProject = sinon.stub().callsArg(2)
|
||||
@ProjectPersistenceManager.clearProject @project_id, @user_id, @callback
|
||||
|
||||
it "should clear the project from the database", ->
|
||||
@ProjectPersistenceManager._clearProjectFromDatabase
|
||||
@@ -52,7 +54,7 @@ describe "ProjectPersistenceManager", ->
|
||||
|
||||
it "should clear the project compile folder", ->
|
||||
@CompileManager.clearProject
|
||||
.calledWith(@project_id)
|
||||
.calledWith(@project_id, @user_id)
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
|
||||
Reference in New Issue
Block a user