Run author side tests always
[gitmo/MooseX-Storage.git] / t / 030_with_checksum.t
index 5d51650..842f7fe 100644 (file)
@@ -3,11 +3,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 25;
+use Test::More;
 use Test::Exception;
 use Test::Deep;
 
 BEGIN {
+    eval "use Digest; use Digest::SHA1";
+    plan skip_all => "Digest and Digest::SHA1 is required for this test" if $@;
+    eval "use JSON::Any";
+    plan skip_all => "JSON::Any is required for this test" if $@; 
+    plan tests => 26;
     use_ok('MooseX::Storage');
 }
 
@@ -37,9 +42,9 @@ BEGIN {
         object => Foo->new( number => 2 ),
     );
     isa_ok( $foo, 'Foo' );
-    
+
     my $packed = $foo->pack;
-    
+
     cmp_deeply(
         $packed,
         {
@@ -50,11 +55,11 @@ BEGIN {
             float     => 10.5,
             array     => [ 1 .. 10 ],
             hash      => { map { $_ => undef } ( 1 .. 10 ) },
-            object    => { 
-                            __CLASS__ => 'Foo', 
-                            __DIGEST__  => re('[0-9a-f]+'),               
-                            number    => 2 
-                         },            
+            object    => {
+                            __CLASS__ => 'Foo',
+                            __DIGEST__  => re('[0-9a-f]+'),
+                            number    => 2
+                         },
         },
         '... got the right frozen class'
     );
@@ -64,7 +69,7 @@ BEGIN {
         $foo2 = Foo->unpack($packed);
     } '... unpacked okay';
     isa_ok($foo2, 'Foo');
-    
+
     cmp_deeply(
         $foo2->pack,
         {
@@ -75,14 +80,14 @@ BEGIN {
             float     => 10.5,
             array     => [ 1 .. 10 ],
             hash      => { map { $_ => undef } ( 1 .. 10 ) },
-            object    => { 
-                            __CLASS__ => 'Foo', 
-                            __DIGEST__  => re('[0-9a-f]+'),               
-                            number    => 2 
-                         },            
+            object    => {
+                            __CLASS__ => 'Foo',
+                            __DIGEST__  => re('[0-9a-f]+'),
+                            number    => 2
+                         },
         },
         '... got the right frozen class'
-    );    
+    );
 }
 
 {
@@ -112,7 +117,9 @@ BEGIN {
 
 SKIP: {
     eval { require Digest::HMAC_SHA1 };
-    skip join( " ", "no Digest::HMAC", ( $@ =~ /\@INC/ ? () : do { chomp(my $e = $@); "($e)" } ) ), 14 if $@;
+    skip join( " ", "no Digest::HMAC", ( $@ =~ /\@INC/ ? () : do { chomp(my $e = $@); "($e)" } ) ), 15 if $@;
+
+    local $::DEBUG = 1;
 
     my $foo = Foo->new(
         number => 10,
@@ -127,6 +134,8 @@ SKIP: {
     my $frozen1 = $foo->freeze( digest => [ "HMAC_SHA1", "secret" ] );
     ok( length($frozen1), "got frozen data" );
 
+    $::DEBUG = 0;
+
     my $d2 = Digest::HMAC_SHA1->new("s3cr3t");
 
     my $frozen2 = $foo->freeze( digest => $d2 );
@@ -134,12 +143,16 @@ SKIP: {
 
     cmp_ok( $frozen1, "ne", $frozen2, "versions are different" );
 
+    is( $frozen1, $foo->freeze( digest => [ HMAC_SHA1 => "secret" ] ), "refreeze" );
+
+$::DEBUG = 1;
+
     my $foo1 = eval { Foo->thaw( $frozen1, digest => [ "HMAC_SHA1", "secret" ] ) };
     my $e = $@;
 
     ok( $foo1, "thawed" );
     ok( !$e, "no error" ) || diag $e;
-    
+
     my $foo2 = eval { Foo->thaw( $frozen2, digest => $d2 ) };
     $e = $@;