mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Pass the start
and end
options down to fs.createReadStream
, and test for same.
This commit is contained in:
parent
57aedefdd3
commit
d88736e3b5
2 changed files with 18 additions and 5 deletions
|
@ -33,7 +33,7 @@ module.exports =
|
|||
_callback = () ->
|
||||
filteredName = filterName name
|
||||
logger.log location:location, name:filteredName, "getting file"
|
||||
sourceStream = fs.createReadStream "#{location}/#{filteredName}"
|
||||
sourceStream = fs.createReadStream "#{location}/#{filteredName}", opts
|
||||
sourceStream.on 'error', (err) ->
|
||||
logger.err err:err, location:location, name:name, "Error reading from file"
|
||||
if err.code = 'ENOENT'
|
||||
|
|
|
@ -69,14 +69,27 @@ describe "FSPersistorManagerTests", ->
|
|||
done()
|
||||
|
||||
describe "getFileStream", ->
|
||||
beforeEach ->
|
||||
@opts = {}
|
||||
|
||||
it "should use correct file location", (done) ->
|
||||
@Fs.createReadStream.returns(
|
||||
on:->
|
||||
)
|
||||
@FSPersistorManager.getFileStream @location, @name1, (err,res)=>
|
||||
@Fs.createReadStream.returns({on: ->})
|
||||
@FSPersistorManager.getFileStream @location, @name1, @opts, (err,res) =>
|
||||
@Fs.createReadStream.calledWith("#{@location}/#{@name1Filtered}").should.equal.true
|
||||
done()
|
||||
|
||||
describe "with start and end options", ->
|
||||
|
||||
beforeEach ->
|
||||
@opts = {start: 0, end: 8}
|
||||
|
||||
it 'should pass the options to createReadStream', (done) ->
|
||||
@Fs.createReadStream.returns({on: ->})
|
||||
@FSPersistorManager.getFileStream @location, @name1, @opts, (err,res)=>
|
||||
@Fs.createReadStream.calledWith("#{@location}/#{@name1Filtered}", @opts).should.equal true
|
||||
done()
|
||||
|
||||
|
||||
describe "copyFile", ->
|
||||
beforeEach ->
|
||||
@ReadStream=
|
||||
|
|
Loading…
Reference in a new issue