X-Git-Url: http://git.pjr.cc/?p=nodejs-repoproxy.git;a=blobdiff_plain;f=unittests%2Funify.js;fp=unittests%2Funify.js;h=7eabb9a79aa601e05fafaf979a077a5259374cff;hp=0000000000000000000000000000000000000000;hb=d9c7eb8248208029df200a897d680914cd0f337f;hpb=c3e6676d533e875b020d231075aac04e4b885677 diff --git a/unittests/unify.js b/unittests/unify.js new file mode 100644 index 0000000..7eabb9a --- /dev/null +++ b/unittests/unify.js @@ -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); +} +