Skip to content

Commit

Permalink
removed Metabase::Fact::TestFact from tests
Browse files Browse the repository at this point in the history
Using private Test::Metabase::StringFact from t/lib instead
  • Loading branch information
xdg committed Apr 9, 2009
1 parent 923829d commit 2990983
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
2 changes: 1 addition & 1 deletion t/index/flatfile.t
Expand Up @@ -30,7 +30,7 @@ ok( my $index = $TEST->test_index, 'created an index' );
isa_ok( $index, 'Metabase::Index::FlatFile' );

ok( my $fact = $TEST->test_fact, "created a fact" );
isa_ok( $fact, 'Metabase::Fact::TestFact' );
isa_ok( $fact, 'Test::Metabase::StringFact' );

ok( my $guid = $archive->store( $fact ), "stored a fact" );

Expand Down
15 changes: 15 additions & 0 deletions t/lib/Test/Metabase/Report.pm
@@ -0,0 +1,15 @@
package Test::Metabase::Report;
use 5.006;
use strict;
use warnings;
use base 'Metabase::Report';

__PACKAGE__->load_fact_classes;

sub report_spec {
return {
Test::Metabase::Fact => "1+", # zero or more
}
}

1;
21 changes: 21 additions & 0 deletions t/lib/Test/Metabase/StringFact.pm
@@ -0,0 +1,21 @@
package Test::Metabase::StringFact;
use 5.006;
use strict;
use warnings;
use base 'Metabase::Fact::String';

sub content_metadata {
my $self = shift;
return {
'size' => [ Num => length $self->content ],
};
}

sub validate_content {
my $self = shift;
$self->SUPER::validate_content;
die __PACKAGE__ . " content length must be greater than zero\n"
if length $self->content < 0;
}

1;
19 changes: 16 additions & 3 deletions t/lib/Test/Metabase/Util.pm
Expand Up @@ -19,7 +19,7 @@ has test_gateway => (
default => sub {
require Metabase::Analyzer::Test;
my $gateway = Metabase::Gateway->new({
fact_classes => [ 'Metabase::Fact::TestFact' ],
fact_classes => [ 'Test::Metabase::StringFact' ],
});
}
);
Expand All @@ -29,8 +29,21 @@ has test_fact => (
isa => 'Metabase::Fact',
lazy => 1,
default => sub {
require Metabase::Fact::TestFact;
Metabase::Fact::TestFact->new(
require Test::Metabase::StringFact;
Test::Metabase::StringFact->new(
resource => 'JOHNDOE/Foo-Bar-1.23.tar.gz',
content => "I smell something fishy.",
);
},
);

has test_report => (
is => 'ro',
isa => 'Metabase::Fact',
lazy => 1,
default => sub {
require Test::Metabase::StringFact;
Test::Metabase::StringFact->new(
resource => 'JOHNDOE/Foo-Bar-1.23.tar.gz',
content => "I smell something fishy.",
);
Expand Down
2 changes: 1 addition & 1 deletion t/librarian/simple.t
Expand Up @@ -26,7 +26,7 @@ require_ok( 'Metabase::Librarian' );
ok( my $librarian = $TEST->test_librarian, 'created librarian' );

ok( my $fact = $TEST->test_fact, "created a fact" );
isa_ok( $fact, 'Metabase::Fact::TestFact' );
isa_ok( $fact, 'Test::Metabase::StringFact' );

ok(
my $guid = $librarian->store($fact, { user_id => 'Larry' }),
Expand Down
6 changes: 3 additions & 3 deletions t/storage/filesystem.t
Expand Up @@ -13,7 +13,7 @@ use File::Temp ();
use File::Path ();

use lib 't/lib';
use Metabase::Fact::TestFact;
use Test::Metabase::StringFact;

#--------------------------------------------------------------------------#

Expand Down Expand Up @@ -42,12 +42,12 @@ lives_ok {
$archive = Metabase::Archive::Filesystem->new(root_dir => "$temp_root");
} "created store at '$temp_root'";

my $fact = Metabase::Fact::TestFact->new(
my $fact = Test::Metabase::StringFact->new(
resource => $dist_id,
content => "I smell something fishy.",
);

isa_ok( $fact, 'Metabase::Fact::TestFact' );
isa_ok( $fact, 'Test::Metabase::StringFact' );

ok( my $guid = $archive->store( $fact ), "stored a fact" );

Expand Down

0 comments on commit 2990983

Please sign in to comment.