initial version for archive docs in S3
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
sinon = require "sinon"
|
||||
chai = require("chai")
|
||||
chai.should()
|
||||
{ObjectId} = require "mongojs"
|
||||
async = require "async"
|
||||
|
||||
DocstoreClient = require "./helpers/DocstoreClient"
|
||||
|
||||
describe "Archiving all docs", ->
|
||||
beforeEach (done) ->
|
||||
@project_id = ObjectId()
|
||||
@docs = [{
|
||||
_id: ObjectId()
|
||||
lines: ["one", "two", "three"]
|
||||
rev: 2
|
||||
}, {
|
||||
_id: ObjectId()
|
||||
lines: ["aaa", "bbb", "ccc"]
|
||||
rev: 4
|
||||
}, {
|
||||
_id: ObjectId()
|
||||
lines: ["111", "222", "333"]
|
||||
rev: 6
|
||||
}]
|
||||
jobs = for doc in @docs
|
||||
do (doc) =>
|
||||
(callback) =>
|
||||
DocstoreClient.createDoc @project_id, doc._id, doc.lines, (err)=>
|
||||
doc.lines[0] = doc.lines[0]+" added"
|
||||
DocstoreClient.updateDoc @project_id, doc._id, doc.lines, callback
|
||||
async.series jobs, done
|
||||
|
||||
it "should archive all the docs", (done) ->
|
||||
DocstoreClient.archiveAllDoc @project_id, (error, res) =>
|
||||
res.statusCode.should.equal 204
|
||||
done()
|
||||
@@ -1,5 +1,6 @@
|
||||
request = require("request").defaults(jar: false)
|
||||
{db, ObjectId} = require("../../../../app/js/mongojs")
|
||||
settings = require("settings-sharelatex")
|
||||
|
||||
module.exports = DocstoreClient =
|
||||
|
||||
@@ -16,28 +17,31 @@ module.exports = DocstoreClient =
|
||||
|
||||
getDoc: (project_id, doc_id, qs, callback = (error, res, body) ->) ->
|
||||
request.get {
|
||||
url: "http://localhost:3016/project/#{project_id}/doc/#{doc_id}"
|
||||
url: "http://localhost:#{settings.internal.docstore.port}/project/#{project_id}/doc/#{doc_id}"
|
||||
json: true
|
||||
qs:qs
|
||||
}, callback
|
||||
|
||||
getAllDocs: (project_id, callback = (error, res, body) ->) ->
|
||||
request.get {
|
||||
url: "http://localhost:3016/project/#{project_id}/doc"
|
||||
url: "http://localhost:#{settings.internal.docstore.port}/project/#{project_id}/doc"
|
||||
json: true
|
||||
}, callback
|
||||
|
||||
updateDoc: (project_id, doc_id, lines, callback = (error, res, body) ->) ->
|
||||
request.post {
|
||||
url: "http://localhost:3016/project/#{project_id}/doc/#{doc_id}"
|
||||
url: "http://localhost:#{settings.internal.docstore.port}/project/#{project_id}/doc/#{doc_id}"
|
||||
json:
|
||||
lines: lines
|
||||
}, callback
|
||||
|
||||
deleteDoc: (project_id, doc_id, callback = (error, res, body) ->) ->
|
||||
request.del {
|
||||
url: "http://localhost:3016/project/#{project_id}/doc/#{doc_id}"
|
||||
url: "http://localhost:#{settings.internal.docstore.port}/project/#{project_id}/doc/#{doc_id}"
|
||||
}, callback
|
||||
|
||||
|
||||
archiveAllDoc: (project_id, callback = (error, res, body) ->) ->
|
||||
request.get {
|
||||
url: "http://localhost:#{settings.internal.docstore.port}/project/#{project_id}/archive"
|
||||
}, callback
|
||||
|
||||
|
||||
Reference in New Issue
Block a user