Commit | Line | Data |
8581da38 |
1 | #!/usr/bin/perl |
2 | use strict; |
3 | use warnings; |
5e15a8a0 |
4 | use Email::MIME; |
5 | |
6 | use Test::More; |
8581da38 |
7 | |
8581da38 |
8 | use Email::Archive; |
ec413087 |
9 | use Email::Archive::Storage::DBIC; |
8581da38 |
10 | |
5e15a8a0 |
11 | my $email = Email::MIME->create( |
8581da38 |
12 | header => [ |
c5f5125c |
13 | From => 'foo@example.com', |
8581da38 |
14 | To => 'drain@example.com', |
15 | Subject => 'Message in a bottle', |
16 | 'Message-ID' => 'helloworld', |
17 | ], |
18 | body => 'hello there!' |
19 | ); |
20 | |
c5f5125c |
21 | my $e = Email::Archive->new(); |
5e15a8a0 |
22 | $e->connect('dbi:SQLite:dbname=t/test.db'); |
8581da38 |
23 | $e->store($email); |
24 | |
25 | my $found = $e->retrieve('helloworld'); |
5e15a8a0 |
26 | cmp_ok($found->header('subject'), 'eq', "Message in a bottle", |
27 | "can find stored message by ID"); |
28 | |
ec413087 |
29 | my $e_dbic = Email::Archive->new( |
30 | storage => Email::Archive::Storage::DBIC->new, |
31 | ); |
32 | $e_dbic->connect('dbi:SQLite:dbname=t/test_dbic.db'); |
33 | $e_dbic->store($email); |
34 | |
35 | $found = $e_dbic->retrieve('helloworld'); |
36 | cmp_ok($found->header('subject'), 'eq', "Message in a bottle", |
37 | "can find stored message by ID"); |
38 | |
39 | |
5e15a8a0 |
40 | done_testing; |
41 | unlink 't/test.db'; |
ec413087 |
42 | unlink 't/dbic_test.db'; |