|
@@ -10,7 +10,7 @@ fs = require("fs")
|
|
|
request = require("request")
|
|
request = require("request")
|
|
|
settings = require("settings-sharelatex")
|
|
settings = require("settings-sharelatex")
|
|
|
|
|
|
|
|
-describe "Sending a file", ->
|
|
|
|
|
|
|
+describe "Filestore", ->
|
|
|
|
|
|
|
|
before (done)->
|
|
before (done)->
|
|
|
@localFileReadPath = "/tmp/filestore_acceptence_tests_file_read.txt"
|
|
@localFileReadPath = "/tmp/filestore_acceptence_tests_file_read.txt"
|
|
@@ -41,13 +41,13 @@ describe "Sending a file", ->
|
|
|
describe "with a file on the server", ->
|
|
describe "with a file on the server", ->
|
|
|
|
|
|
|
|
beforeEach (done)->
|
|
beforeEach (done)->
|
|
|
- @timeout(1000 * 5)
|
|
|
|
|
- @fileUrl = "#{@filestoreUrl}/project/acceptence_tests/file/#{Math.random()}"
|
|
|
|
|
|
|
+ @timeout(1000 * 10)
|
|
|
|
|
+ @file_id = Math.random()
|
|
|
|
|
+ @fileUrl = "#{@filestoreUrl}/project/acceptence_tests/file/#{@file_id}"
|
|
|
|
|
|
|
|
writeStream = request.post(@fileUrl)
|
|
writeStream = request.post(@fileUrl)
|
|
|
|
|
|
|
|
- writeStream.on "end", =>
|
|
|
|
|
- done()
|
|
|
|
|
|
|
+ writeStream.on "end", done
|
|
|
fs.createReadStream(@localFileReadPath).pipe writeStream
|
|
fs.createReadStream(@localFileReadPath).pipe writeStream
|
|
|
|
|
|
|
|
it "should be able get the file back", (done)->
|
|
it "should be able get the file back", (done)->
|
|
@@ -57,12 +57,30 @@ describe "Sending a file", ->
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
it "should be able to delete the file", (done)->
|
|
it "should be able to delete the file", (done)->
|
|
|
|
|
+ @timeout(1000 * 20)
|
|
|
request.del @fileUrl, (err, response, body)=>
|
|
request.del @fileUrl, (err, response, body)=>
|
|
|
response.statusCode.should.equal 204
|
|
response.statusCode.should.equal 204
|
|
|
request.get @fileUrl, (err, response, body)=>
|
|
request.get @fileUrl, (err, response, body)=>
|
|
|
body.indexOf("NoSuchKey").should.not.equal -1
|
|
body.indexOf("NoSuchKey").should.not.equal -1
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ it "should be able to copy files", (done)->
|
|
|
|
|
+ @timeout(1000 * 20)
|
|
|
|
|
+
|
|
|
|
|
+ newProjectID = "acceptence_tests_copyied_project"
|
|
|
|
|
+ newFileId = Math.random()
|
|
|
|
|
+ newFileUrl = "#{@filestoreUrl}/project/#{newProjectID}/file/#{newFileId}"
|
|
|
|
|
+ opts =
|
|
|
|
|
+ uri: newFileUrl
|
|
|
|
|
+ json:
|
|
|
|
|
+ source:
|
|
|
|
|
+ project_id:"acceptence_tests"
|
|
|
|
|
+ file_id: @file_id
|
|
|
|
|
+ request.put opts, (err)=>
|
|
|
|
|
+ request.del @fileUrl, (err, response, body)=>
|
|
|
|
|
+ request.get newFileUrl, (err, response, body)=>
|
|
|
|
|
+ body.should.equal @constantFileContent
|
|
|
|
|
+ done()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|