archiving document history now sends all changes to s3
This commit is contained in:
@@ -71,27 +71,27 @@ describe "Archiving updates", ->
|
||||
throw error if error?
|
||||
done()
|
||||
|
||||
it "should remain one doc change", (done) ->
|
||||
it "should remain zero doc change", (done) ->
|
||||
db.docHistory.count { doc_id: ObjectId(@doc_id) }, (error, count) ->
|
||||
throw error if error?
|
||||
count.should.equal 1
|
||||
count.should.equal 0
|
||||
done()
|
||||
|
||||
it "should remained doc marked as inS3", (done) ->
|
||||
db.docHistory.findOne { doc_id: ObjectId(@doc_id) }, (error, doc) ->
|
||||
it "should have docHistoryStats marked as inS3", (done) ->
|
||||
db.docHistoryStats.findOne { doc_id: ObjectId(@doc_id) }, (error, doc) ->
|
||||
throw error if error?
|
||||
doc.inS3.should.equal true
|
||||
done()
|
||||
|
||||
it "should remained doc have last version", (done) ->
|
||||
db.docHistory.findOne { doc_id: ObjectId(@doc_id) }, (error, doc) ->
|
||||
it "should have docHistoryStats with the last version", (done) ->
|
||||
db.docHistoryStats.findOne { doc_id: ObjectId(@doc_id) }, (error, doc) ->
|
||||
throw error if error?
|
||||
doc.v.should.equal 20
|
||||
doc.lastVersion.should.equal 20
|
||||
done()
|
||||
|
||||
it "should store nineteen doc changes in S3", (done) ->
|
||||
it "should store twenty doc changes in S3", (done) ->
|
||||
TrackChangesClient.getS3Doc @project_id, @doc_id, (error, res, doc) =>
|
||||
doc.length.should.equal 19
|
||||
doc.length.should.equal 20
|
||||
done()
|
||||
|
||||
describe "unarchiving a doc's updates", ->
|
||||
@@ -107,7 +107,8 @@ describe "Archiving updates", ->
|
||||
done()
|
||||
|
||||
it "should remove doc marked as inS3", (done) ->
|
||||
db.docHistory.count { doc_id: ObjectId(@doc_id), inS3 : true }, (error, count) ->
|
||||
db.docHistoryStats.findOne {doc_id: ObjectId(@doc_id)}, (error, doc) ->
|
||||
throw error if error?
|
||||
count.should.equal 0
|
||||
doc.should.not.contain.key('inS3')
|
||||
doc.should.not.contain.key('lastVersion')
|
||||
done()
|
||||
|
||||
@@ -61,8 +61,8 @@ describe "DocArchiveManager", ->
|
||||
beforeEach ->
|
||||
@update = { _id: ObjectId(), op: "op", meta: "meta", v: "v"}
|
||||
@MongoManager.getDocChangesCount = sinon.stub().callsArg(1)
|
||||
@MongoManager.getArchivedDocChanges = sinon.stub().callsArgWith(1, null, 0)
|
||||
@MongoManager.getLastCompressedUpdate = sinon.stub().callsArgWith(1, null, @update)
|
||||
@MongoManager.getArchivedDocStatus = sinon.stub().callsArgWith(1, null, 0)
|
||||
@MongoManager.peekLastCompressedUpdate = sinon.stub().callsArgWith(1, null, @update, @update.v)
|
||||
@MongoAWS.archiveDocHistory = sinon.stub().callsArg(3)
|
||||
@MongoManager.markDocHistoryAsArchiveInProgress = sinon.stub().callsArg(2)
|
||||
@MongoManager.markDocHistoryAsArchived = sinon.stub().callsArg(2)
|
||||
@@ -71,7 +71,7 @@ describe "DocArchiveManager", ->
|
||||
it "should run markDocHistoryAsArchived with doc_id and update", ->
|
||||
@MongoManager.markDocHistoryAsArchived
|
||||
.calledWith(
|
||||
@doc_id, @update
|
||||
@doc_id, @update.v
|
||||
)
|
||||
.should.equal true
|
||||
it "should call the callback", ->
|
||||
@@ -107,7 +107,7 @@ describe "DocArchiveManager", ->
|
||||
|
||||
describe "unArchiveDocChanges", ->
|
||||
beforeEach ->
|
||||
@MongoManager.getArchivedDocChanges = sinon.stub().callsArg(1)
|
||||
@MongoManager.getArchivedDocStatus = sinon.stub().callsArgWith(1, null, {inS3: true})
|
||||
@MongoAWS.unArchiveDocHistory = sinon.stub().callsArg(2)
|
||||
@MongoManager.markDocHistoryAsUnarchived = sinon.stub().callsArg(1)
|
||||
@DocArchiveManager.unArchiveDocChanges @project_id, @doc_id, @callback
|
||||
|
||||
@@ -406,21 +406,20 @@ describe "MongoManager", ->
|
||||
@db.docHistory.count
|
||||
.calledWith({
|
||||
doc_id: ObjectId(@doc_id)
|
||||
inS3 : { $exists : false }
|
||||
})
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
describe "getArchivedDocChanges", ->
|
||||
describe "getArchivedDocStatus", ->
|
||||
beforeEach ->
|
||||
@db.docHistory =
|
||||
count: sinon.stub().callsArg(1)
|
||||
@MongoManager.getArchivedDocChanges @doc_id, @callback
|
||||
@db.docHistoryStats =
|
||||
findOne: sinon.stub().callsArg(2)
|
||||
@MongoManager.getArchivedDocStatus @doc_id, @callback
|
||||
|
||||
it "should return if there is any archived doc changes", ->
|
||||
@db.docHistory.count
|
||||
@db.docHistoryStats.findOne
|
||||
.calledWith({
|
||||
doc_id: ObjectId(@doc_id)
|
||||
inS3: {$exists: true}
|
||||
@@ -433,15 +432,16 @@ describe "MongoManager", ->
|
||||
describe "markDocHistoryAsArchived", ->
|
||||
beforeEach ->
|
||||
@update = { _id: ObjectId(), op: "op", meta: "meta", v: "v"}
|
||||
@db.docHistoryStats =
|
||||
update: sinon.stub().callsArg(3)
|
||||
@db.docHistory =
|
||||
update: sinon.stub().callsArg(2)
|
||||
remove: sinon.stub().callsArg(1)
|
||||
@MongoManager.markDocHistoryAsArchived @doc_id, @update, @callback
|
||||
@MongoManager.markDocHistoryAsArchived @doc_id, @update.v, @callback
|
||||
|
||||
it "should update last doc change with inS3 flag", ->
|
||||
@db.docHistory.update
|
||||
it "should update doc status with inS3 flag", ->
|
||||
@db.docHistoryStats.update
|
||||
.calledWith({
|
||||
_id: ObjectId(@update._id)
|
||||
doc_id: ObjectId(@doc_id)
|
||||
},{
|
||||
$set : { inS3 : true }
|
||||
})
|
||||
@@ -451,8 +451,7 @@ describe "MongoManager", ->
|
||||
@db.docHistory.remove
|
||||
.calledWith({
|
||||
doc_id: ObjectId(@doc_id)
|
||||
inS3 : { $exists : false }
|
||||
v: { $lt : @update.v }
|
||||
v: { $lte : @update.v }
|
||||
expiresAt: {$exists : false}
|
||||
})
|
||||
.should.equal true
|
||||
@@ -462,18 +461,16 @@ describe "MongoManager", ->
|
||||
|
||||
describe "markDocHistoryAsUnarchived", ->
|
||||
beforeEach ->
|
||||
@db.docHistory =
|
||||
update: sinon.stub().callsArg(3)
|
||||
@db.docHistoryStats =
|
||||
update: sinon.stub().callsArg(2)
|
||||
@MongoManager.markDocHistoryAsUnarchived @doc_id, @callback
|
||||
|
||||
it "should remove any doc changes inS3 flag", ->
|
||||
@db.docHistory.update
|
||||
@db.docHistoryStats.update
|
||||
.calledWith({
|
||||
doc_id: ObjectId(@doc_id)
|
||||
},{
|
||||
$unset : { inS3 : true }
|
||||
},{
|
||||
multi: true
|
||||
$unset : { inS3 : true, lastVersion: true }
|
||||
})
|
||||
.should.equal true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user