-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use strict; | ||
use warnings; | ||
use Test::Roo; | ||
use Test::FailWarnings; | ||
use Test::Fatal; | ||
use Test::Requires qw/MongoDB/; | ||
|
||
my $conn = eval { MongoDB::MongoClient->new; }; | ||
plan skip_all => "No MongoDB on localhost" | ||
unless eval { $conn->get_database("admin")->run_command( [ ismaster => 1 ] ) }; | ||
|
||
use lib 't/lib'; | ||
|
||
with 'TestFixtures'; | ||
|
||
sub _build_meerkat_options { | ||
my ($self) = @_; | ||
return { | ||
model_namespace => 'My::Model', | ||
collection_namespace => 'Bad::Collection', | ||
database_name => 'test', | ||
}; | ||
} | ||
|
||
test 'meerkat will propogate custom collection errors' => sub { | ||
my $self = shift; | ||
|
||
my $err = exception { $self->meerkat->collection('Doom') }; | ||
like( | ||
$err, | ||
qr/This attribute will blow up on construction/, | ||
"Caught error from custom collection object" | ||
); | ||
|
||
my $coll; | ||
$err = exception { $coll = $self->meerkat->collection('Person') }; | ||
ok( !$err, 'No exception when custom collection package is missing' ); | ||
isa_ok( $coll, 'Meerkat::Collection' ); | ||
}; | ||
|
||
run_me; | ||
done_testing; | ||
# COPYRIGHT | ||
# vim: ts=4 sts=4 sw=4 et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use strict; | ||
use warnings; | ||
|
||
package Bad::Collection::Doom; | ||
|
||
use Moose 2; | ||
extends 'Meerkat::Collection'; | ||
|
||
has bad_attribute => ( | ||
is => 'ro', | ||
default => sub { | ||
die "This attribute will blow up on construction"; | ||
} | ||
); | ||
|
||
1; |