diff --git a/test/lib/cloudfunc.html b/test/lib/cloudfunc.html
new file mode 100644
index 00000000..73036fb6
--- /dev/null
+++ b/test/lib/cloudfunc.html
@@ -0,0 +1,25 @@
+
-
+
+ ..
+ <dir>
+ .
+ --- --- ---
+
-
+
+ applnk
+ <dir>
+ root
+ rwx r-x r-x
+
-
+
+ prefdm
+ 1.30kb
+ root
+ rwx r-x r-x
+
\ No newline at end of file
diff --git a/test/lib/cloudfunc.js b/test/lib/cloudfunc.js
new file mode 100644
index 00000000..b5b9ac3a
--- /dev/null
+++ b/test/lib/cloudfunc.js
@@ -0,0 +1,86 @@
+(function() {
+ 'use strict';
+
+ var DIR = __dirname + '/../../',
+ LIBDIR = DIR + 'lib/',
+ HTMLDIR = DIR + 'html/',
+
+ Util = require(LIBDIR + 'util'),
+ CloudFunc = require(LIBDIR + 'cloudfunc'),
+ files = require(LIBDIR + 'server/files'),
+
+ FS_DIR = HTMLDIR + 'fs/',
+ TEMPLATEPATH = FS_DIR + 'file.html',
+ LINK_TEMPLATE_PATH = FS_DIR + 'link.html',
+ PATHTEMPLATE_PATH = FS_DIR + 'path.html',
+ EXPECT_PATH = DIR + 'test/lib/cloudfunc.html',
+
+ Files = [TEMPLATEPATH, PATHTEMPLATE_PATH, LINK_TEMPLATE_PATH, EXPECT_PATH],
+
+ JSON_FILES = {
+ path : '/etc/X11/',
+ files : [{
+ name: 'applnk',
+ size: 'dir',
+ uid : 0,
+ mode: '40755'
+ }, {
+ name: 'prefdm',
+ size: 1328,
+ uid : 0,
+ mode: '100755'
+ }]
+ },
+
+
+ Expect =
+ '' +
+ '
' +
+ '' +
+ '
' +
+ '
' +
+ '/' +
+ '' +
+ 'etc' +
+ '/X11/' +
+ '' +
+ '
';
+
+
+ exports.check = function() {
+ files.read(Files, 'utf-8', function(errors, files) {
+ var i, n, template, pathTemplate, linkTemplate, expect, result;
+
+ if (errors)
+ Util.log(errors);
+ else {
+ Util.time('CloudFunc.buildFromJSON');
+
+ template = files[TEMPLATEPATH];
+ pathTemplate = files[PATHTEMPLATE_PATH];
+ linkTemplate = files[LINK_TEMPLATE_PATH];
+ expect = files[EXPECT_PATH];
+
+ result = CloudFunc.buildFromJSON(JSON_FILES, template, pathTemplate, linkTemplate);
+
+ Expect += expect;
+
+ n = Expect.length;
+ for (i = 0; i < n; i++)
+ if (result[i] !== Expect[i]) {
+ Util.log('Error in char number: ' + i + '\n' +
+ 'Expect: ' + Expect.substr(i) + '\n' +
+ 'Result: ' + result.substr(i) );
+ break;
+ }
+
+ if (i === n)
+ console.log('CloudFunc.buildFromJSON: OK');
+
+ Util.timeEnd('CloudFunc.buildFromJSON');
+ }
+ });
+ };
+})();