diff options
author | dakkar <dakkar@thenautilus.net> | 2016-12-28 18:00:21 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2016-12-28 18:00:21 +0000 |
commit | 3bb7321db17a92a2e6b5fd29be53403c68d453c9 (patch) | |
tree | 7cb93750b6fe3d8db9e12edc1aa69e44e75c1122 | |
parent | simpler command-line script (diff) | |
download | Sietima-3bb7321db17a92a2e6b5fd29be53403c68d453c9.tar.gz Sietima-3bb7321db17a92a2e6b5fd29be53403c68d453c9.tar.bz2 Sietima-3bb7321db17a92a2e6b5fd29be53403c68d453c9.zip |
test for mail_store coercion
-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})); |