acceptance test versioning entity deletions

This commit is contained in:
Hayden Faulds 2017-12-14 16:03:57 +00:00
parent 475e84b039
commit 99a52d48c8
3 changed files with 43 additions and 2 deletions

View file

@ -261,12 +261,12 @@ describe "ProjectStructureChanges", ->
name: 'bar' name: 'bar'
}, (error, res, body) => }, (error, res, body) =>
throw error if error? throw error if error?
example_folder_id_2 = JSON.parse(body)._id @example_folder_id_2 = JSON.parse(body)._id
@owner.request.post { @owner.request.post {
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_1}/move", uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_1}/move",
json: json:
folder_id: example_folder_id_2 folder_id: @example_folder_id_2
}, (error, res, body) => }, (error, res, body) =>
throw error if error? throw error if error?
if res.statusCode < 200 || res.statusCode >= 300 if res.statusCode < 200 || res.statusCode >= 300
@ -288,6 +288,34 @@ describe "ProjectStructureChanges", ->
done() done()
describe "deleting entities", ->
beforeEach () ->
MockDocUpdaterApi.clearProjectStructureUpdates()
it "should version deleting a folder", (done) ->
@owner.request.delete {
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_2}",
}, (error, res, body) =>
throw error if error?
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to delete folder #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
#expect(update.userId).to.equal(@owner._id)
expect(update.pathname).to.equal("/bar/foo/new.tex")
expect(update.newPathname).to.equal("")
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
#expect(update.userId).to.equal(@owner._id)
expect(update.pathname).to.equal("/bar/foo/1pixel.png")
expect(update.newPathname).to.equal("")
done()
describe "tpds", -> describe "tpds", ->
before (done) -> before (done) ->
@tpds_project_name = "tpds-project-#{new ObjectId().toString()}" @tpds_project_name = "tpds-project-#{new ObjectId().toString()}"

View file

@ -33,6 +33,9 @@ module.exports = MockDocUpdaterApi =
@addProjectStructureUpdates(project_id, userId, docUpdates, fileUpdates) @addProjectStructureUpdates(project_id, userId, docUpdates, fileUpdates)
res.sendStatus 200 res.sendStatus 200
app.delete "/project/:project_id/doc/:doc_id", (req, res, next) =>
res.send 204
app.listen 3003, (error) -> app.listen 3003, (error) ->
throw error if error? throw error if error?
.on "error", (error) -> .on "error", (error) ->

View file

@ -23,6 +23,16 @@ module.exports = MockDocStoreApi =
docs = (doc for doc_id, doc of @docs[req.params.project_id]) docs = (doc for doc_id, doc of @docs[req.params.project_id])
res.send JSON.stringify docs res.send JSON.stringify docs
app.delete "/project/:project_id/doc/:doc_id", (req, res, next) =>
{project_id, doc_id} = req.params
if !@docs[project_id]?
res.send 404
else if !@docs[project_id][doc_id]?
res.send 404
else
@docs[project_id][doc_id] = undefined
res.send 204
app.listen 3016, (error) -> app.listen 3016, (error) ->
throw error if error? throw error if error?
.on "error", (error) -> .on "error", (error) ->