1 |
dpavlin |
168 |
#!/usr/bin/env perl |
2 |
|
|
use warnings; |
3 |
|
|
use strict; |
4 |
|
|
|
5 |
|
|
=head1 DESCRIPTION |
6 |
|
|
|
7 |
|
|
test Strix integration |
8 |
|
|
|
9 |
|
|
=cut |
10 |
|
|
|
11 |
dpavlin |
213 |
use Jifty::Test tests => 21; |
12 |
dpavlin |
168 |
|
13 |
|
|
use Data::Dump qw/dump/; |
14 |
|
|
|
15 |
|
|
use_ok('Strix'); |
16 |
|
|
|
17 |
|
|
$Strix::debug = 1 if @ARGV; |
18 |
|
|
my $debug = $Strix::debug; |
19 |
|
|
|
20 |
dpavlin |
174 |
my $instance = 'os-test0604-zg'; |
21 |
|
|
$instance = 'new'; |
22 |
dpavlin |
168 |
|
23 |
dpavlin |
174 |
ok( my $dbh = Strix->dbh( $instance ), 'dbh' ); |
24 |
dpavlin |
168 |
isa_ok( $dbh, 'DBI::db' ); |
25 |
|
|
|
26 |
dpavlin |
174 |
ok( my $strix = Strix->new({ instance => $instance }), 'new' ); |
27 |
dpavlin |
168 |
isa_ok( $strix, 'Strix' ); |
28 |
|
|
|
29 |
dpavlin |
213 |
# cache |
30 |
dpavlin |
216 |
ok( my $path = $strix->cache_path( 'test', 42, 'bar' ), 'cache_path' ); |
31 |
|
|
like( $path, qr/test-42-bar/, 'correct' ); |
32 |
dpavlin |
213 |
|
33 |
|
|
my $data = 'scalar'; |
34 |
|
|
SKIP: { |
35 |
|
|
skip( 'scalars not supported', 2 ); |
36 |
|
|
ok( $strix->write_cache( $data, 'test-scalar' ), 'write_cache scalar' ); |
37 |
|
|
is_deeply( $strix->read_cache( 'test-scalar' ), $data, 'read_cache scalar' ); |
38 |
|
|
} |
39 |
|
|
$data = { foo => 42, bar => 'baz' }; |
40 |
|
|
ok( $strix->write_cache( $data, 'test-hash' ), 'write_cache hash' ); |
41 |
|
|
is_deeply( $strix->read_cache( 'test-hash' ), $data, 'read_cache hash' ); |
42 |
|
|
$data = [ 1, 2, 42 ]; |
43 |
|
|
ok( $strix->write_cache( $data, 'test-array' ), 'write_cache array' ); |
44 |
|
|
is_deeply( $strix->read_cache( 'test-array' ), $data, 'read_cache array' ); |
45 |
|
|
|
46 |
dpavlin |
168 |
my $url = '/'; |
47 |
|
|
|
48 |
|
|
ok( my $category = $strix->category( $url ), "category $url" ); |
49 |
|
|
diag dump( $category ) if $debug; |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
ok( my $layout = $strix->layout( $url ), "layout $url" ); |
53 |
|
|
diag dump( $layout ) if $debug; |
54 |
|
|
ok( $layout->{pre}, 'pre' ); |
55 |
|
|
ok( $layout->{free}, 'free' ); |
56 |
dpavlin |
169 |
|
57 |
dpavlin |
193 |
ok( my @sites = $strix->sites, "sites" ); |
58 |
|
|
diag dump( @sites ) if $debug; |
59 |
dpavlin |
213 |
|
60 |
|
|
ok( my $nav = $strix->site_navigation( 1, 1 ), "site_navigation" ); |
61 |
|
|
diag dump( $nav ) if $debug; |
62 |
|
|
|
63 |
|
|
ok( my $nav2 = $strix->site_navigation( 1, 1 ), "site_navigation (again)" ); |
64 |
|
|
is_deeply( $nav, $nav2, 'same' ); |