Revision 216 (by dpavlin, 2008/06/20 21:49:16) put cache all over the place and simplify it
#!/usr/bin/env perl
use warnings;
use strict;

=head1 DESCRIPTION

test Strix integration

=cut

use Jifty::Test tests => 21;

use Data::Dump qw/dump/;

use_ok('Strix');

$Strix::debug = 1 if @ARGV;
my $debug = $Strix::debug;

my $instance = 'os-test0604-zg';
$instance = 'new';

ok( my $dbh = Strix->dbh( $instance ), 'dbh' );
isa_ok( $dbh, 'DBI::db' );

ok( my $strix = Strix->new({ instance => $instance }), 'new' );
isa_ok( $strix, 'Strix' );

# cache
ok( my $path = $strix->cache_path( 'test', 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" );
diag dump( $category ) if $debug;


ok( my $layout = $strix->layout( $url ), "layout $url" );
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' );