diff options
Diffstat (limited to 't/tests/sietima/mailstore.t')
-rw-r--r-- | t/tests/sietima/mailstore.t | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/t/tests/sietima/mailstore.t b/t/tests/sietima/mailstore.t index c03fc1c..7a2aa08 100644 --- a/t/tests/sietima/mailstore.t +++ b/t/tests/sietima/mailstore.t @@ -4,6 +4,49 @@ use Test::Sietima; use Email::Stuffer; use Path::Tiny; +package TestClassWithMS { + use Moo; + use Sietima::Policy; + with 'Sietima::Role::WithMailStore'; +}; + +subtest 'Role::WithMailStore' => sub { + subtest 'plain instance' => sub { + require Test::Sietima::MailStore; + ok( + lives { + TestClassWithMS->new({ + mail_store => Test::Sietima::MailStore->new, + }) + }, + 'passing a test instance should work', + ); + }; + subtest 'type coercion' => sub { + my $tc; + my $root = Path::Tiny->tempdir; + ok( + lives { + $tc = TestClassWithMS->new({ + mail_store => { + class => 'Sietima::MailStore::FS', + root => $root, + }, + }) + }, + 'passing a hashref should work (and load the class)', + ); + is( + $tc->mail_store, + object { + prop blessed => 'Sietima::MailStore::FS'; + call root => $root; + }, + 'the mailstore should be built correctly', + ); + }; +}; + sub mkmail($id) { Email::Stuffer ->from("from-${id}\@example.com") @@ -131,14 +174,10 @@ sub test_store($store) { } subtest 'test store' => sub { - require Test::Sietima::MailStore; - test_store(Test::Sietima::MailStore->new); }; subtest 'file store' => sub { - require Sietima::MailStore::FS; - my $root = Path::Tiny->tempdir; test_store(Sietima::MailStore::FS->new({root => $root})); |