-
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.
Added ResourceTester tests for the virtual and physical resources
- Loading branch information
1 parent
36414fc
commit aea18ee
Showing
23 changed files
with
146 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,93 @@ | ||
"use strict"; | ||
var webdav = require('../../lib/index.js'), | ||
path = require('path'), | ||
fs = require('fs') | ||
|
||
function clearFolder(rootFolder) | ||
{ | ||
const files = fs.readdirSync(rootFolder); | ||
for(let f of files) | ||
{ | ||
if(f === '.gitkeep') | ||
continue; | ||
|
||
f = path.join(rootFolder, f); | ||
const s = fs.statSync(f); | ||
if(s.isFile()) | ||
fs.unlinkSync(f); | ||
else | ||
{ | ||
clearFolder(f); | ||
fs.rmdirSync(f); | ||
} | ||
} | ||
} | ||
|
||
module.exports = (test, options, index) => test('resource tester on the physical resources', (isValid, server) => | ||
{ | ||
isValid = isValid.multiple(2, server); | ||
|
||
const rootFolder = path.join(__dirname, 'resourceTesterPhysical'); | ||
clearFolder(rootFolder); | ||
|
||
let fid = 0; | ||
new webdav.ResourceTester({ | ||
canHaveVirtualFolderChildren: false, | ||
canHaveVirtualFileChildren: false, | ||
canGetLastModifiedDate: true, | ||
canGetCreationDate: true, | ||
canRemoveChildren: false, | ||
canHaveChildren: false, | ||
canGetChildren: false, | ||
canGetMimeType: true, | ||
canBeCreated: true, | ||
canBeDeleted: true, | ||
canBeRenamed: true, | ||
canGetSize: true, | ||
canBeMoved: true, | ||
canWrite: true, | ||
canRead: true | ||
}, | ||
(willCreate, cb) => { | ||
const name = path.join(rootFolder, 'testFile' + (++fid).toString()); | ||
fs.writeFile(name, '', () => { | ||
cb(new webdav.PhysicalFile(name)) | ||
}) | ||
} | ||
).run((results) => { | ||
isValid(results.all.isValid, results.all.errors); | ||
}) | ||
|
||
let fid2 = 0; | ||
new webdav.ResourceTester({ | ||
canHaveVirtualFolderChildren: true, | ||
canHaveVirtualFileChildren: true, | ||
canGetLastModifiedDate: true, | ||
canGetCreationDate: true, | ||
canRemoveChildren: true, | ||
canHaveChildren: true, | ||
canGetChildren: true, | ||
canGetMimeType: false, | ||
canBeCreated: true, | ||
canBeDeleted: true, | ||
canBeRenamed: true, | ||
canGetSize: false, | ||
canBeMoved: true, | ||
canWrite: false, | ||
canRead: false | ||
}, | ||
(willCreate, cb) => { | ||
const name = path.join(rootFolder, 'testFolder' + (++fid2).toString()); | ||
if(!willCreate) | ||
{ | ||
fs.mkdir(name, () => { | ||
cb(new webdav.PhysicalFolder(name)) | ||
}) | ||
} | ||
else | ||
cb(new webdav.PhysicalFolder(name)) | ||
} | ||
).run((results) => { | ||
isValid(results.all.isValid, results.all.errors); | ||
}) | ||
}) |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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 @@ | ||
content1content2 |
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 @@ | ||
test |
Empty file.
Empty file.
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,51 @@ | ||
"use strict"; | ||
var webdav = require('../../lib/index.js') | ||
|
||
module.exports = (test, options, index) => test('resource tester on the virtual resources', (isValid, server) => | ||
{ | ||
isValid = isValid.multiple(2, server); | ||
|
||
new webdav.ResourceTester({ | ||
canHaveVirtualFolderChildren: false, | ||
canHaveVirtualFileChildren: false, | ||
canGetLastModifiedDate: true, | ||
canGetCreationDate: true, | ||
canRemoveChildren: false, | ||
canHaveChildren: false, | ||
canGetChildren: false, | ||
canGetMimeType: true, | ||
canBeCreated: true, | ||
canBeDeleted: true, | ||
canBeRenamed: true, | ||
canGetSize: true, | ||
canBeMoved: true, | ||
canWrite: true, | ||
canRead: true | ||
}, | ||
(willCreate, cb) => cb(new webdav.VirtualFile('test')) | ||
).run((results) => { | ||
isValid(results.all.isValid, results.all.errors); | ||
}) | ||
|
||
new webdav.ResourceTester({ | ||
canHaveVirtualFolderChildren: true, | ||
canHaveVirtualFileChildren: true, | ||
canGetLastModifiedDate: true, | ||
canGetCreationDate: true, | ||
canRemoveChildren: true, | ||
canHaveChildren: true, | ||
canGetChildren: true, | ||
canGetMimeType: false, | ||
canBeCreated: true, | ||
canBeDeleted: true, | ||
canBeRenamed: true, | ||
canGetSize: false, | ||
canBeMoved: true, | ||
canWrite: false, | ||
canRead: false | ||
}, | ||
(willCreate, cb) => cb(new webdav.VirtualFolder('test')) | ||
).run((results) => { | ||
isValid(results.all.isValid, results.all.errors); | ||
}) | ||
}) |