Skip to content

Commit

Permalink
Added tests for the new features of the 'addSubTree' method
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Sep 4, 2017
1 parent 6692f4c commit 0f2c1d9
Showing 1 changed file with 85 additions and 11 deletions.
96 changes: 85 additions & 11 deletions test/v2/tests.ts/server/addSubTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,81 @@ import * as request from 'request'

export default ((info, isValid) =>
{
const server = info.init(1);
const server = info.init(2);

function check(path : string, callback : () => void) : void
{
info.req({
url: 'http://localhost:' + server.options.port + '/' + path,
method: 'PROPFIND',
headers: {
Depth: 0
const server2 = info.startServer();
server2.rootFileSystem().addSubTree(v2.ExternalRequestContext.create(server2), {
'emptyFolder1': v2.ResourceType.Directory,
'folder1': {
'emptyFolder2': v2.ResourceType.Directory,
'file2': 'Hello!',
'folder2': {
'emptyFolder3': v2.ResourceType.Directory,
'file3': 'Hello!'
},
'folder2x': {
'emptyFolder3x': v2.ResourceType.Directory,
'file3x': 'Hello!'
}
}, v2.HTTPCodes.MultiStatus, () => {
callback();
},
'file1': 'Hello!'
}, (e) => {
const check = (path : string, callback : () => void) =>
{
info.req({
url: 'http://localhost:' + server2.options.port + '/' + path,
method: 'PROPFIND',
headers: {
Depth: 0
}
}, v2.HTTPCodes.MultiStatus, () => {
callback();
})
}
const checkContent = (path : string, content : string, callback : () => void) =>
{
info.req({
url: 'http://localhost:' + server2.options.port + '/' + path,
method: 'GET'
}, v2.HTTPCodes.OK, (res, rContent) => {
if(rContent === content)
return callback();
isValid(false);
})
}

check('file1', () => {
check('emptyFolder1', () => {
check('folder1', () => {
check('folder1/file2', () => {
check('folder1/emptyFolder2', () => {
check('folder1/folder2', () => {
check('folder1/folder2/emptyFolder3', () => {
check('folder1/folder2/file3', () => {
check('folder1/folder2x', () => {
check('folder1/folder2x/emptyFolder3x', () => {
check('folder1/folder2x/file3x', () => {
checkContent('file1', 'Hello!', () => {
checkContent('folder1/file2', 'Hello!', () => {
checkContent('folder1/folder2/file3', 'Hello!', () => {
checkContent('folder1/folder2x/file3x', 'Hello!', () => {
isValid(true);
})
})
})
})
})
})
})
})
}
})
})
})
})
})
})
})
})

server.rootFileSystem().addSubTree(v2.ExternalRequestContext.create(server), {
'emptyFolder1': v2.ResourceType.Directory,
Expand All @@ -35,6 +96,19 @@ export default ((info, isValid) =>
},
'file1': v2.ResourceType.File
}, (e) => {
const check = (path : string, callback : () => void) =>
{
info.req({
url: 'http://localhost:' + server.options.port + '/' + path,
method: 'PROPFIND',
headers: {
Depth: 0
}
}, v2.HTTPCodes.MultiStatus, () => {
callback();
})
}

check('file1', () => {
check('emptyFolder1', () => {
check('folder1', () => {
Expand Down

0 comments on commit 0f2c1d9

Please sign in to comment.