fixed namespaces
[p5sagit/Email-Archive.git] / t / basic.t
CommitLineData
8581da38 1#!/usr/bin/perl
2use strict;
3use warnings;
5e15a8a0 4use Email::MIME;
5
6use Test::More;
8581da38 7
8581da38 8use Email::Archive;
ec413087 9use Email::Archive::Storage::DBIC;
8581da38 10
5e15a8a0 11my $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 21my $e = Email::Archive->new();
5e15a8a0 22$e->connect('dbi:SQLite:dbname=t/test.db');
8581da38 23$e->store($email);
24
25my $found = $e->retrieve('helloworld');
5e15a8a0 26cmp_ok($found->header('subject'), 'eq', "Message in a bottle",
27 "can find stored message by ID");
28
ec413087 29my $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');
36cmp_ok($found->header('subject'), 'eq', "Message in a bottle",
37 "can find stored message by ID");
38
39
5e15a8a0 40done_testing;
41unlink 't/test.db';
ec413087 42unlink 't/dbic_test.db';