8f959f5d6c70edc316d5c92760ff679e622e3197
[p5sagit/Email-Archive.git] / t / email-archive.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Email::MIME;
5
6 use Test::More;
7
8 use Email::Archive;
9
10 my $email = Email::MIME->create(
11     header => [
12       From    => 'foo@example.com',
13       To      => 'drain@example.com',
14       Subject => 'Message in a bottle',
15       'Message-ID' => 'helloworld',
16     ],
17     body => 'hello there!'
18 );
19
20 my $e = Email::Archive->new();
21 $e->connect('dbi:SQLite:dbname=t/test.db');
22 $e->store($email);
23
24 my $found = $e->retrieve('helloworld');
25 cmp_ok($found->header('subject'), 'eq', "Message in a bottle",
26   "can find stored message by ID");
27
28 done_testing;
29 unlink 't/test.db';