Catalyst::Plugin::Cache configuration thingy
[catagits/Catalyst-Plugin-Cache.git] / t / basic.t
index 89700b2..8e20614 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -11,6 +11,11 @@ use ok "Catalyst::Plugin::Cache";
 {
     package MockApp;
     use base qw/Catalyst::Plugin::Cache/;
+    
+    sub registered_plugins {}
+
+    my %config;
+    sub config { \%config };
 
     package MemoryCache;
     use Storable qw/freeze thaw/;
@@ -18,7 +23,7 @@ use ok "Catalyst::Plugin::Cache";
     sub new { bless {}, shift }
     sub get { ${thaw($_[0]{$_[1]}) || return} };
     sub set { $_[0]{$_[1]} = freeze(\$_[2]) };
-    sub delete { delete $_[0]{$_[1]} };
+    sub remove { delete $_[0]{$_[1]} };
 }
 
 MockApp->setup;
@@ -56,20 +61,19 @@ dies_ok {
 
 
 can_ok( $c, "default_cache_backend" );
-is( $c->default_cache_backend, $c->cache, "cache with no args retrurns default" );
 
 can_ok( $c, "choose_cache_backend_wrapper" );
 can_ok( $c, "choose_cache_backend" );
 
 can_ok( $c, "cache_set" );
 can_ok( $c, "cache_get" );
-can_ok( $c, "cache_delete" );
+can_ok( $c, "cache_remove" );
 
 $c->cache_set( foo => "bar" );
 is( $c->cache_get("foo"), "bar", "set" );
 
-$c->cache_delete( "foo" );
-is( $c->cache_get("foo"), undef, "delete" );
+$c->cache_remove( "foo" );
+is( $c->cache_get("foo"), undef, "remove" );
 
 MockApp->register_cache_backend( elk => MemoryCache->new );
 
@@ -81,3 +85,8 @@ $c->cache_set( foo => "gorch", backend => "elk" );
 is( $c->cache_get("foo"), undef, "set to custom backend (get from non custom)" );
 is( $c->cache_get("foo", backend => "elk"), "gorch", "set to custom backend (get from custom)" );
 
+my $cache_elk = $c->cache( backend => "elk" );
+my $cache_norm = $c->cache();
+
+is( $cache_norm->get("foo"), undef, "default curried cache has no foo");
+is( $cache_elk->get("foo"), "gorch", "curried custom backend has foo" );