Skip to content

Commit

Permalink
Upgraded the test framework of the v2
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 28, 2017
1 parent deb443b commit a9edc7e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion test/v2/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ module.exports = (callback, options) => {
callCallback();
}

info.exit = (msg) => {
callback(false, msg);
}

var allGood = true;
var allMsg;
info.isValid = function(good, msg, error)
Expand All @@ -182,7 +186,7 @@ module.exports = (callback, options) => {

try
{
setTimeout(() => info.isValid(false, 'Timeout'), options.timeout);
setTimeout(() => info.exit('Timeout'), options.timeout);
process.nextTick(() => require(fx).default(info, (good, msg, e) => info.isValid(good, msg, e)));
}
catch(ex)
Expand Down
2 changes: 1 addition & 1 deletion test/v2/tests.ts/options/.createFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { v2 } from '../../../../lib/index.js'

export function starter(server : v2.WebDAVServer, info : TestInfo, isValid : TestCallback, name : string, expect : string[], reject : string[], callback : (allowHeader ?: string[]) => void) : void
{
server.rootFileSystem().addSubTree(info.ctx, {
server.rootFileSystem().addSubTree(v2.RequestContext.createExternal(server), {
'folder': v2.ResourceType.Directory,
'file': v2.ResourceType.File,
'hybrid': v2.ResourceType.Hybrid,
Expand Down
5 changes: 3 additions & 2 deletions test/v2/tests.ts/readDir/.createDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function starter(server : v2.WebDAVServer, info : TestInfo, isValid : Tes
'subFile2'
];
const name = 'folder';
server.rootFileSystem().addSubTree(info.ctx, {
const ctx = v2.RequestContext.createExternal(server);
server.rootFileSystem().addSubTree(ctx, {
[name]: {
'subFolder1': v2.ResourceType.Directory,
'subFolder2': v2.ResourceType.Directory,
Expand All @@ -20,7 +21,7 @@ export function starter(server : v2.WebDAVServer, info : TestInfo, isValid : Tes
}, (e) => {
if(e) return isValid(false, 'Cannot call "addSubTree(...)".', e);

server.getResource(info.ctx, '/' + name, (e, r) => {
server.getResource(ctx, '/' + name, (e, r) => {
if(e) return isValid(false, 'Could not find /' + name, e);

callback(r, subFiles);
Expand Down
5 changes: 3 additions & 2 deletions test/v2/tests.ts/readWrite/.createFileTxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export function starter(server : v2.WebDAVServer, info : TestInfo, isValid : Tes
const type = _callback ? _type as v2.ResourceType : v2.ResourceType.File;

const name = 'file.txt';
server.rootFileSystem().addSubTree(info.ctx, {
const ctx = v2.RequestContext.createExternal(server);
server.rootFileSystem().addSubTree(ctx, {
[name]: type
}, (e) => {
if(e) return isValid(false, 'Cannot call "addSubTree(...)".', e);

server.getResource(info.ctx, '/' + name, (e, r) => {
server.getResource(ctx, '/' + name, (e, r) => {
if(e) return isValid(false, 'Could not find //' + name, e);

if(!type.isFile)
Expand Down

0 comments on commit a9edc7e

Please sign in to comment.