#!/usr/bin/perl -w
use strict; 

use lib qw(./t ./ ./DADA/perllib ../ ../DADA/perllib ../../ ../../DADA/perllib 
	
	/Users/justin/Documents/DadaMail/build/bundle/perllib
	
	); 
BEGIN{$ENV{NO_DADA_MAIL_CONFIG_IMPORT} = 1}


use dada_test_config; 
#dada_test_config::wipe_out;

use Test::More qw(no_plan);  

use DADA::Config;
use DADA::App::Guts; 
use DADA::MailingList::Subscribers; 
use DADA::MailingList::Settings; 
use DADA::Mail::Send; 
use DADA::App::Messages; 

my $list = dada_test_config::create_test_list;
my $mh; 



# This will fail: 
eval {$mh = DADA::Mail::Send->new();};
ok($@); 
like($@, qr/You MUST pass the \-list paramater\!/); 
 
$mh = DADA::Mail::Send->new(
	  		{
				-list => $list
			}
		); 

ok($mh->isa('DADA::Mail::Send'), "returns the right type of object!"); 

ok($mh->test    == 0); 
ok($mh->test(1) == 1); 
ok($mh->test    == 1); 
ok($mh->test(0) == 0); 
ok($mh->test    == 0); 

my $d_test_send_file = $mh->test_send_file; 

ok($mh->test_send_file eq $DADA::Config::TMP . '/test_send_file.txt');
ok($mh->test_send_file('/some/path/to/a/file.txt') eq '/some/path/to/a/file.txt');
ok($mh->test_send_file eq '/some/path/to/a/file.txt'); 
ok($mh->test_send_file($d_test_send_file) eq $DADA::Config::TMP . '/test_send_file.txt'); 
ok($mh->test_send_file eq $DADA::Config::TMP . '/test_send_file.txt');


 






dada_test_config::remove_test_list;
dada_test_config::wipe_out;


sub slurp { 
	
		
		my ($file) = @_;

        local($/) = wantarray ? $/ : undef;
        local(*F);
        my $r;
        my (@r);

        open(F, "<$file") || die "open $file: $!";
        @r = <F>;
        close(F) || die "close $file: $!";

        return $r[0] unless wantarray;
        return @r;

}




