#!perl -Tw
BEGIN {
use_ok(
'FCGI::Buffer'
);
}
CACHED: {
delete
$ENV
{
'REMOTE_ADDR'
};
delete
$ENV
{
'HTTP_USER_AGENT'
};
my
$b
= FCGI::Buffer->new();
ok(
$b
->is_cached() == 0);
ok(
$b
->can_cache() == 1);
SKIP: {
eval
{
CHI->
import
;
};
skip
'CHI not installed'
, 2
if
$@;
diag(
"Using CHI $CHI::VERSION"
);
my
$cache
= CHI->new(
driver
=>
'Memory'
,
datastore
=> {});
$b
->init({
cache
=>
$cache
,
cache_key
=>
'xyzzy'
,
logger
=> MyLogger->new()
});
ok(!
$b
->is_cached());
my
$c
= {
'body'
=>
''
,
'etag'
=>
''
,
'headers'
=>
''
};
$cache
->set(
'xyzzy'
, Storable::freeze(
$c
));
ok(
$b
->is_cached());
}
}
sub
new {
my
(
$proto
,
%args
) =
@_
;
my
$class
=
ref
(
$proto
) ||
$proto
;
return
bless
{ },
$class
;
}
sub
debug {
my
$self
=
shift
;
my
$message
=
shift
;
if
(
$ENV
{
'TEST_VERBOSE'
}) {
::diag(
$message
);
}
}