Skip to content

Commit

Permalink
Added tests for the streaming PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 14, 2017
1 parent 34a19f1 commit ae0cf70
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/tests/writeCreateVirtualFile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use strict";
var webdav = require('../../lib/index.js'),
var request = require('request'),
stream = require('stream'),
Client = require('webdav-fs')

module.exports = (test, options, index) => test('write/create a virtual file', (isValid, server) =>
{
isValid = isValid.multiple(1, server);
isValid = isValid.multiple(2, server);
const _ = (e, cb) => {
if(e)
isValid(false, e);
Expand All @@ -22,4 +23,18 @@ module.exports = (test, options, index) => test('write/create a virtual file', (
isValid(!e)
})
}))

const content = 'This is the content of the file!';
const str = new stream.PassThrough();
str.end(content);
const destStream = request({
url: 'http://localhost:' + (options.port + index) + '/newFile.txt',
method: 'PUT'
});
destStream.on('complete', (res, body) => {
wfs.readFile('/newFile.txt', (e, c) => _(e, () => {
isValid(c.toString() === content.toString(), 'The content written with streaming must create and store the content.');
}))
})
str.pipe(destStream);
})

0 comments on commit ae0cf70

Please sign in to comment.