-
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
105580f
commit feb22d6
Showing
4 changed files
with
288 additions
and
0 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,48 @@ | ||
var webdav = require('../../lib/index.js'), | ||
Client = require("webdav-fs"), | ||
path = require('path'), | ||
fs = require('fs') | ||
|
||
module.exports = (test, options, index) => test('delete a physical file', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
server.start(options.port + index); | ||
isValid = isValid.multiple(1, server); | ||
|
||
var wfs = Client( | ||
"http://127.0.0.1:" + (options.port + index) | ||
); | ||
|
||
const fileName = 'file.txt'; | ||
const filePath = path.join(__dirname, 'deletePhysicalFile', fileName); | ||
if(!fs.existsSync(filePath)) | ||
fs.writeFileSync(filePath, 'Test!'); | ||
|
||
server.rootResource.addChild(new webdav.PhysicalFile(filePath), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + fileName, (e, stat) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.unlink('/' + fileName, (e) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
fs.exists(filePath, (exists) => { | ||
isValid(!exists) | ||
}) | ||
}) | ||
}) | ||
}); | ||
}) |
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,106 @@ | ||
var webdav = require('../../lib/index.js'), | ||
Client = require("webdav-fs"), | ||
path = require('path'), | ||
fs = require('fs') | ||
|
||
module.exports = (test, options, index) => test('delete a physical folder', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
server.start(options.port + index); | ||
isValid = isValid.multiple(2, server); | ||
|
||
var wfs = Client( | ||
"http://127.0.0.1:" + (options.port + index) | ||
); | ||
|
||
const folderName = 'emptyFolder'; | ||
const folderPath = path.join(__dirname, 'deletePhysicalFolder', folderName); | ||
if(!fs.existsSync(folderPath)) | ||
fs.mkdirSync(folderPath); | ||
|
||
server.rootResource.addChild(new webdav.PhysicalFolder(folderPath), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + folderName, (e, stat) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.unlink('/' + folderName, (e) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
fs.exists(folderPath, (exists) => { | ||
isValid(!exists) | ||
}) | ||
}) | ||
}) | ||
}); | ||
|
||
const folderName2 = 'notEmptyFolder'; | ||
const folderPath2 = path.join(__dirname, 'deletePhysicalFolder', folderName2); | ||
if(!fs.existsSync(folderPath2)) | ||
fs.mkdirSync(folderPath2); | ||
const fd = new webdav.PhysicalFolder(folderPath2); | ||
|
||
const folderName3 = 'folder'; | ||
const folderPath3 = path.join(folderPath2, folderName3); | ||
if(!fs.existsSync(folderPath3)) | ||
fs.mkdirSync(folderPath3); | ||
fd.addChild(new webdav.PhysicalFolder(folderPath3), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
const fileName4 = 'file.txt'; | ||
const filePath4 = path.join(folderPath2, fileName4); | ||
if(!fs.existsSync(filePath4)) | ||
fs.writeFileSync(filePath4, 'Test!'); | ||
fd.addChild(new webdav.PhysicalFile(filePath4), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
server.rootResource.addChild(fd, e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + folderName2, (e, stat) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.unlink('/' + folderName2, (e) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
fs.exists(folderPath2, (exists) => { | ||
isValid(!exists) | ||
}) | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
}) |
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,46 @@ | ||
var webdav = require('../../lib/index.js'), | ||
Client = require("webdav-fs") | ||
|
||
module.exports = (test, options, index) => test('delete a virtual file', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
server.start(options.port + index); | ||
isValid = isValid.multiple(2, server); | ||
|
||
var wfs = Client( | ||
"http://127.0.0.1:" + (options.port + index) | ||
); | ||
|
||
const fileName = 'file.txt'; | ||
server.rootResource.addChild(new webdav.VirtualFile(fileName), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + fileName, (e, stat) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.unlink('/' + fileName, (e) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + fileName, (e, stat) => { | ||
isValid(!!e) | ||
}) | ||
}) | ||
}) | ||
}); | ||
|
||
wfs.unlink('/fileNotFound.txt', (e) => { | ||
isValid(!!e) | ||
}) | ||
}) |
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,88 @@ | ||
var webdav = require('../../lib/index.js'), | ||
Client = require("webdav-fs") | ||
|
||
module.exports = (test, options, index) => test('delete a virtual folder', isValid => | ||
{ | ||
var server = new webdav.WebDAVServer(); | ||
server.start(options.port + index); | ||
isValid = isValid.multiple(2, server); | ||
|
||
var wfs = Client( | ||
"http://127.0.0.1:" + (options.port + index) | ||
); | ||
|
||
const folderName = 'folder'; | ||
server.rootResource.addChild(new webdav.VirtualFolder(folderName), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + folderName, (e, stat) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.unlink('/' + folderName, (e) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + folderName, (e, stat) => { | ||
isValid(!!e) | ||
}) | ||
}) | ||
}) | ||
}); | ||
|
||
const folderName2 = 'notEmptyFolder'; | ||
const vd = new webdav.VirtualFolder(folderName2); | ||
vd.addChild(new webdav.VirtualFolder('folder'), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
vd.addChild(new webdav.VirtualFile('file.txt'), e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
server.rootResource.addChild(vd, e => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + folderName2, (e, stat) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.unlink('/' + folderName2, (e) => { | ||
if(e) | ||
{ | ||
isValid(false, e) | ||
return; | ||
} | ||
|
||
wfs.stat('/' + folderName2, (e, stat) => { | ||
isValid(!!e) | ||
}) | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
}) |