lots of work on the request pipeline
[nodejs-repoproxy.git] / unittests / unify.js
diff --git a/unittests/unify.js b/unittests/unify.js
new file mode 100644 (file)
index 0000000..7eabb9a
--- /dev/null
@@ -0,0 +1,49 @@
+var router = require("../lib/router.js");
+
+global.repoproxy = new Object();
+global.repoproxy.cacheDir = "./cache";
+
+var paths = new Array();
+var i = 0;
+paths[0] ="/pub/something/";
+paths[1] ="/pub/something";
+paths[2] ="/pub/fedora";
+paths[3] ="/pub/fedora/";
+paths[4] ="/pub/ts.js";
+paths[5] ="/ts.js";
+paths[6] ="/fedora";
+paths[7] = "/fedora/";
+paths[8] = "/";
+paths[9] = "/fedora/some/directory/in/here/";
+paths[10] = "/fedora/some/directory/in/here/file";
+
+trial(paths[i]);
+
+function trial(path) {
+       
+       console.log("\n\n\n\n\nBEGIN TEST on '%s'", path);
+       
+       var req = new Object();
+       var res = new Object();
+       req.url = path;
+       
+       res.writeHead = function(n, o) {
+               console.log("write head for: ", n);
+               console.log("and o: ",o);
+       }
+       
+       res.end = function() {
+               return;
+       }
+       
+       var result = router.unifyRequest(req, res, function(uni) {
+               console.log("I is ", i);
+               console.log("Uni is ", uni);
+               console.log("from path: ", path);
+               
+               i++;
+               
+               if(typeof paths[i] != "undefined") trial(paths[i]);
+       }, true);
+}
+