Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

Commit

Permalink
Fix test/cache.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinkihaveacat committed Feb 18, 2013
1 parent 49e78fd commit 912daf6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
node utils.js
node simple.js
#node cache.js
node cache.js
#node filter.js
96 changes: 49 additions & 47 deletions test/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,72 +21,74 @@ var expected_hit = [
{ headers: { "x-cache": "HIT", "cache-control": "max-age=60, public" }, body: "Hello, World" }
];

lib.group({
"static": lib.getStatic.bind(null, response, lib.SERVER_PORT),
"cache": lib.getCacheLocal
}, function (group) {
var proxy = fishback.createServer(group.cache, '0.0.0.0', lib.SERVER_PORT);
proxy.listen(lib.PROXY_PORT, function () {
[lib.getCacheLocal].forEach(function (callback) {

lib.step([
callback(function (cache) {

function (callback) {
var proxy = new fishback.Proxy(cache, lib.getMockClient(response));

Date.prototype.getTime = function() {
return NOW;
}
proxy.listen(lib.PROXY_PORT, function () {

lib.step([

lib.request(expected_miss.length, lib.PROXY_PORT, function (actual) {
for (var i = 0; i < actual.length; i++) {
lib.responseEqual(actual[i], expected_miss[i]);
function (callback) {

Date.prototype.getTime = function() {
return NOW;
}
callback();
});

},
lib.request(expected_miss.length, lib.PROXY_PORT, function (actual) {
for (var i = 0; i < actual.length; i++) {
lib.responseEqual(actual[i], expected_miss[i]);
}
callback();
});

// No cache misses
function (callback) {
},

Date.prototype.getTime = function() {
return NOW + 30000;
}
// No cache misses
function (callback) {

lib.request(expected_hit.length, lib.PROXY_PORT, function (actual) {
for (var i = 0; i < actual.length; i++) {
lib.responseEqual(actual[i], expected_hit[i]);
Date.prototype.getTime = function() {
return NOW + 30000;
}
callback();
});

},
lib.request(expected_hit.length, lib.PROXY_PORT, function (actual) {
for (var i = 0; i < actual.length; i++) {
lib.responseEqual(actual[i], expected_hit[i]);
}
callback();
});

// Should get a cache miss the first time, because we're 120 seconds
// on.
function (callback) {
},

Date.prototype.getTime = function() {
return NOW + 120000;
}
// Should get a cache miss the first time, because we're 120 seconds
// on.
function (callback) {

lib.request(expected_miss.length, lib.PROXY_PORT, function (actual) {
for (var i = 0; i < actual.length; i++) {
lib.responseEqual(actual[i], expected_miss[i]);
Date.prototype.getTime = function() {
return NOW + 120000;
}
callback();
});

},
lib.request(expected_miss.length, lib.PROXY_PORT, function (actual) {
for (var i = 0; i < actual.length; i++) {
lib.responseEqual(actual[i], expected_miss[i]);
}
callback();
});

},

function (callback) {
proxy.close();
callback();
}

function (callback) {
proxy.close();
group.cache.close();
group.static.close();
callback();
}
]);

});

]);
});

});

0 comments on commit 912daf6

Please sign in to comment.