File: mbox.t

package info (click to toggle)
libemail-sender-perl 2.601-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: perl: 2,276; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 826 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!perl
use strict;
use warnings;

use lib 't/lib';
use Test::Email::Sender::Util;
use File::Spec ();
use File::Temp ();

use Test::More tests => 4;

my $tempdir = File::Temp::tempdir(CLEANUP => 1);
my $mbox    = File::Spec->catfile($tempdir, 'mbox');

use Email::Sender::Transport::Mbox;

my $message = readfile('t/messages/simple.msg');

my $sender = Email::Sender::Transport::Mbox->new({ filename => $mbox });

for (1..2) {
  my $result = $sender->send(
    join('', @$message),
    {
      to   => [ 'rjbs@example.com' ],
      from => 'rjbs@example.biz',
    },
  );

  isa_ok($result, 'Email::Sender::Success', "delivery result");
}

ok(-f $mbox, "$mbox exists now");

open my $fh, '<', $mbox or die "couldn't open $mbox to read: $!";
my $line = <$fh>;

like( $line, qr/^From rjbs\@example\.biz/, "added a From_ line" );