summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-05-17 23:43:58 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-05-17 23:43:58 +0200
commitc708681021c7832a231b199e0e15159b8d75f3d0 (patch)
treecc9c9cda1c214ccd7f09f6922dc3be7bd8833f1a
parent76a1ba5f056fbdce14054128faedb0512bfee2d0 (diff)
Further tests
-rw-r--r--lib/App/Hashl.pm3
-rw-r--r--t/29-app-hashl.t42
2 files changed, 41 insertions, 4 deletions
diff --git a/lib/App/Hashl.pm b/lib/App/Hashl.pm
index 58af4a6..8d3187c 100644
--- a/lib/App/Hashl.pm
+++ b/lib/App/Hashl.pm
@@ -149,7 +149,8 @@ sub ignored {
sub ignore {
my ($self, $file) = @_;
- push(@{ $self->{ignored}->{hashes} }, $file);
+ $self->delete_file($file);
+ push(@{ $self->{ignored}->{hashes} }, $self->hash_file($file));
}
sub save {
diff --git a/t/29-app-hashl.t b/t/29-app-hashl.t
index fbd2e99..fffe9cc 100644
--- a/t/29-app-hashl.t
+++ b/t/29-app-hashl.t
@@ -3,10 +3,12 @@ use strict;
use warnings;
use 5.010;
-use Test::More tests => 13;
+use Test::More tests => 22;
use_ok('App::Hashl');
+my $IGNORED = '// ignored';
+
my $hashl = App::Hashl->new();
isa_ok($hashl, 'App::Hashl');
@@ -26,5 +28,39 @@ is($hashl->file_in_db('t/in/4'), undef, 'file not in db');
is_deeply([$hashl->files()], [], 'no files in empty db');
is_deeply([$hashl->ignored()], [], 'no ignored files in empty db');
-ok($hashl->ignore('hash123'), 'ignore hash');
-is_deeply([$hashl->ignored()], ['hash123'], 'ignore hash');
+my $test_hash = $hashl->hash_file('t/in/4');
+ok($hashl->add_file(
+ file => 't/in/4',
+ path => 't/in/4',
+ mtime => 123,
+ size => 4,
+ ),
+ 'Add new file'
+);
+is_deeply($hashl->file('t/in/4'),
+ {
+ hash => $test_hash,
+ size => 4,
+ mtime => 123,
+ },
+ 'hashl->file okay'
+);
+
+ok($hashl->file_in_db('t/in/4'), 'file is now in db');
+ok($hashl->hash_in_db($test_hash), 'hash is in db');
+
+ok($hashl->ignore('t/in/4'), 'ignore file');
+is($hashl->file_in_db('t/in/4'), $IGNORED, 'file no longer in db');
+
+is_deeply([$hashl->ignored()], [$test_hash], 'file is ignored');
+
+ok($hashl->save('t/in/hashl.db'), 'save db');
+
+undef $hashl;
+
+$hashl = App::Hashl->new_from_file('t/in/hashl.db');
+isa_ok($hashl, 'App::Hashl');
+unlink('t/in/hashl.db');
+
+is($hashl->file_in_db('t/in/4'), $IGNORED, 'file still ignored');
+is_deeply([$hashl->files()], [], 'no files in db');