--- t/50-strix.t 2008/06/15 23:59:51 168 +++ t/50-strix.t 2008/06/20 20:44:18 213 @@ -8,7 +8,7 @@ =cut -use Jifty::Test tests => 9; +use Jifty::Test tests => 21; use Data::Dump qw/dump/; @@ -17,14 +17,32 @@ $Strix::debug = 1 if @ARGV; my $debug = $Strix::debug; -my $site = 'os-test0604-zg'; +my $instance = 'os-test0604-zg'; +$instance = 'new'; -ok( my $dbh = Strix->dbh( $site ), 'dbh' ); +ok( my $dbh = Strix->dbh( $instance ), 'dbh' ); isa_ok( $dbh, 'DBI::db' ); -ok( my $strix = Strix->new({ site => $site }), 'new' ); +ok( my $strix = Strix->new({ instance => $instance }), 'new' ); isa_ok( $strix, 'Strix' ); +# cache +ok( my $path = $strix->cache_path( 'test-%d-%s', 42, 'bar' ), 'cache_path' ); +like( $path, qr/test-42-bar$/, 'correct' ); + +my $data = 'scalar'; +SKIP: { +skip( 'scalars not supported', 2 ); +ok( $strix->write_cache( $data, 'test-scalar' ), 'write_cache scalar' ); +is_deeply( $strix->read_cache( 'test-scalar' ), $data, 'read_cache scalar' ); +} +$data = { foo => 42, bar => 'baz' }; +ok( $strix->write_cache( $data, 'test-hash' ), 'write_cache hash' ); +is_deeply( $strix->read_cache( 'test-hash' ), $data, 'read_cache hash' ); +$data = [ 1, 2, 42 ]; +ok( $strix->write_cache( $data, 'test-array' ), 'write_cache array' ); +is_deeply( $strix->read_cache( 'test-array' ), $data, 'read_cache array' ); + my $url = '/'; ok( my $category = $strix->category( $url ), "category $url" ); @@ -35,3 +53,12 @@ diag dump( $layout ) if $debug; ok( $layout->{pre}, 'pre' ); ok( $layout->{free}, 'free' ); + +ok( my @sites = $strix->sites, "sites" ); +diag dump( @sites ) if $debug; + +ok( my $nav = $strix->site_navigation( 1, 1 ), "site_navigation" ); +diag dump( $nav ) if $debug; + +ok( my $nav2 = $strix->site_navigation( 1, 1 ), "site_navigation (again)" ); +is_deeply( $nav, $nav2, 'same' );