-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
031794c
commit a4c9e63
Showing
5 changed files
with
103 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var webdav = require('../../lib/index.js'), | ||
Client = require('webdav-fs'), | ||
path = require('path'), | ||
fs = require('fs') | ||
|
||
module.exports = (test, options, index) => test('stat of physical resources', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
isValid = isValid.multiple(2, server); | ||
|
||
const content = 'Content!!!'; | ||
|
||
const folderName = 'testFolder'; | ||
const folderPath = path.join(__dirname, 'statPhysical', folderName); | ||
if(!fs.existsSync(folderPath)) | ||
fs.mkdirSync(folderPath); | ||
|
||
const folder = new webdav.PhysicalFolder(folderPath); | ||
server.rootResource.addChild(folder, e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
const fileName = 'testFile.txt'; | ||
const filePath = path.join(folderPath, fileName); | ||
|
||
if(!fs.existsSync(filePath)) | ||
fs.writeFileSync(filePath, content); | ||
|
||
folder.addChild(new webdav.PhysicalFile(filePath), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
server.start(options.port + index); | ||
|
||
var wfs = Client( | ||
"http://127.0.0.1:" + (options.port + index) | ||
); | ||
|
||
wfs.stat('/' + folderName + '/' + fileName, (e, stat) => { | ||
isValid(!e && stat.name === fileName && stat.size === content.length && stat.isFile(), 'File error'); | ||
}) | ||
|
||
wfs.stat('/' + folderName, (e, stat) => { | ||
isValid(!e && stat.isDirectory(), 'Folder error'); | ||
}) | ||
}); | ||
}); | ||
}) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Content!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var webdav = require('../../lib/index.js'), | ||
Client = require('webdav-fs'), | ||
request = require('request') | ||
|
||
module.exports = (test, options, index) => test('stat of virtual resources', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
isValid = isValid.multiple(2, server); | ||
|
||
const content = 'Content!!!'; | ||
|
||
const folder = new webdav.VirtualFolder('testFolder'); | ||
server.rootResource.addChild(folder, e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
const file = new webdav.VirtualFile('testFile.txt'); | ||
file.content = content; | ||
folder.addChild(file, e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
server.start(options.port + index); | ||
|
||
var wfs = Client( | ||
"http://127.0.0.1:" + (options.port + index) | ||
); | ||
|
||
wfs.stat('/testFolder/testFile.txt', (e, stat) => { | ||
isValid(!e && stat.name === 'testFile.txt' && stat.size === content.length && stat.isFile(), 'File error'); | ||
}) | ||
|
||
wfs.stat('/testFolder', (e, stat) => { | ||
isValid(!e && stat.isDirectory(), 'Folder error'); | ||
}) | ||
|
||
wfs.stat('/notFoundFile.txt', (e, stat) => { | ||
isValid(!!e); | ||
}) | ||
}); | ||
}); | ||
}) |
This file was deleted.
Oops, something went wrong.