fixing repo bits
[nodejs-repoproxy.git] / unittests / unify.js
1 var router = require("../lib/router.js");
2
3 global.repoproxy = new Object();
4 global.repoproxy.cacheDir = "./cache";
5
6 var paths = new Array();
7 var i = 0;
8 paths[0] ="/pub/something/";
9 paths[1] ="/pub/something";
10 paths[2] ="/pub/fedora";
11 paths[3] ="/pub/fedora/";
12 paths[4] ="/pub/ts.js";
13 paths[5] ="/ts.js";
14 paths[6] ="/fedora";
15 paths[7] = "/fedora/";
16 paths[8] = "/";
17 paths[9] = "/fedora/some/directory/in/here/";
18 paths[10] = "/fedora/some/directory/in/here/file";
19
20 trial(paths[i]);
21
22 function trial(path) {
23         
24         console.log("\n\n\n\n\nBEGIN TEST on '%s'", path);
25         
26         var req = new Object();
27         var res = new Object();
28         req.url = path;
29         
30         res.writeHead = function(n, o) {
31                 console.log("write head for: ", n);
32                 console.log("and o: ",o);
33         }
34         
35         res.end = function() {
36                 return;
37         }
38         
39         var result = router.unifyRequest(req, res, function(uni) {
40                 console.log("I is ", i);
41                 console.log("Uni is ", uni);
42                 console.log("from path: ", path);
43                 
44                 i++;
45                 
46                 if(typeof paths[i] != "undefined") trial(paths[i]);
47         }, true);
48 }
49