fix purgeCache in Asset.pm. Add a test for it to Asset.t
This commit is contained in:
parent
963690641e
commit
841e9d5784
2 changed files with 25 additions and 2 deletions
|
|
@ -2369,7 +2369,7 @@ sub purgeCache {
|
||||||
$stow->delete('assetLineage');
|
$stow->delete('assetLineage');
|
||||||
$stow->delete('assetClass');
|
$stow->delete('assetClass');
|
||||||
$stow->delete('assetRevision');
|
$stow->delete('assetRevision');
|
||||||
eval{$self->session->cache->delete("asset".$self->getId.$self->get("revisionDate"))};
|
$self->session->cache->remove("asset".$self->getId.$self->get("revisionDate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
25
t/Asset.t
25
t/Asset.t
|
|
@ -21,7 +21,7 @@ use Test::Deep;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
use WebGUI::Exception;
|
use WebGUI::Exception;
|
||||||
|
|
||||||
plan tests => 62;
|
plan tests => 65;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
|
@ -159,6 +159,29 @@ my $session = WebGUI::Test->session;
|
||||||
is $asset->title, 'Root', 'got the right asset';
|
is $asset->title, 'Root', 'got the right asset';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
note "new (caching), purgeCache";
|
||||||
|
my $testId = 'wg8TestAsset0000000001';
|
||||||
|
my $revisionDate = time();
|
||||||
|
$session->db->write("insert into asset (assetId) VALUES (?)", [$testId]);
|
||||||
|
$session->db->write("insert into assetData (assetId, revisionDate) VALUES (?,?)", [$testId, $revisionDate]);
|
||||||
|
|
||||||
|
my $datum;
|
||||||
|
$datum = $session->cache->get("asset".$testId.$revisionDate);
|
||||||
|
is $datum, undef, 'no cache exists for the test assetId, yet';
|
||||||
|
|
||||||
|
my $testAsset = WebGUI::Asset->new($session, $testId, $revisionDate);
|
||||||
|
$datum = $session->cache->get("asset".$testId.$revisionDate);
|
||||||
|
isnt $datum, undef, 'cache was created on new (from db)';
|
||||||
|
|
||||||
|
$testAsset->purgeCache();
|
||||||
|
$datum = $session->cache->get("asset".$testId.$revisionDate);
|
||||||
|
is $datum, undef, 'purgeCache removes the cache entry';
|
||||||
|
|
||||||
|
$session->db->write("delete from asset where assetId=?", [$testId]);
|
||||||
|
$session->db->write("delete from assetData where assetId=?", [$testId]);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
note "write, update";
|
note "write, update";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue