-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added full unit-testing of the chunked-upload-routes library and fixe…
…d some bugs that came out of that venture
- Loading branch information
1 parent
2175455
commit 2bfc617
Showing
5 changed files
with
392 additions
and
22 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
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,38 @@ | ||
var typeHelper = require.main.require('libs/helpers/typeHelper'), | ||
cache = {}; | ||
function create(key, val, ttl, callback) { | ||
cache[key] = val; | ||
if(typeHelper.isFunction(callback)) { | ||
callback(null, true); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
function restore(key, callback) { | ||
if(typeHelper.isFunction(callback)) { | ||
callback(null, {key: key, value: cache[key]}); | ||
} else { | ||
return {key: key, value: cache[key]}; | ||
} | ||
} | ||
|
||
function update(key, val, ttl, callback) { | ||
return create(key, val, ttl, callback); | ||
} | ||
|
||
function del(key, callback) { | ||
delete cache[key]; | ||
if(typeHelper.isFunction(callback)) { | ||
callback(null, 1); | ||
} else { | ||
return 1; | ||
} | ||
} | ||
|
||
module.exports = { | ||
"create": create, | ||
"restore": restore, | ||
"update": update, | ||
"delete": del | ||
}; |
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,41 @@ | ||
/* global Buffer */ | ||
var fs = require('fs'); | ||
|
||
function getFileStats(path, callback) { | ||
// TODO get temp stats object | ||
callback(null, {}); | ||
} | ||
|
||
function createFile(path, buffer, offset, length, callback) { | ||
callback(null); | ||
} | ||
|
||
function writeFileChunk(path, buffer, offset, length, position, callback) { | ||
callback(null); | ||
} | ||
|
||
function deleteFile(path, callback) { | ||
callback(null); | ||
} | ||
|
||
function readFile(path, callback) { | ||
callback(null, new Buffer(0)); | ||
} | ||
|
||
function readFileChunk(path, buffer, offset, length, position, callback) { | ||
callback(null, 0, new Buffer(0)); | ||
} | ||
|
||
function renameFile(path, newPath, callback) { | ||
callback(null); | ||
} | ||
|
||
module.exports = { | ||
GetFileStats: getFileStats, | ||
CreateFile: createFile, | ||
WriteFileChunk: writeFileChunk, | ||
DeleteFile: deleteFile, | ||
ReadFile: readFile, | ||
ReadFileChunk: readFileChunk, | ||
RenameFile: renameFile | ||
}; |
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
Oops, something went wrong.