fixed namespaces
[p5sagit/Email-Archive.git] / t / basic.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 use Email::Archive::Storage::DBIC;
10
11 my $email = Email::MIME->create(
12     header => [
13       From    => 'foo@example.com',
14       To      => 'drain@example.com',
15       Subject => 'Message in a bottle',
16       'Message-ID' => 'helloworld',
17     ],
18     body => 'hello there!'
19 );
20
21 my $e = Email::Archive->new();
22 $e->connect('dbi:SQLite:dbname=t/test.db');
23 $e->store($email);
24
25 my $found = $e->retrieve('helloworld');
26 cmp_ok($found->header('subject'), 'eq', "Message in a bottle",
27   "can find stored message by ID");
28
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
40 done_testing;
41 unlink 't/test.db';
42 unlink 't/dbic_test.db';