1 | #! /usr/bin/perl |
---|
2 | # |
---|
3 | # Copyright (c) 2004-2007 - Consultas, PKG.fr |
---|
4 | # |
---|
5 | # This file is part of A2P. |
---|
6 | # |
---|
7 | # A2P is free software; you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation; either version 2 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # A2P is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with A2P; if not, write to the Free Software |
---|
19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
20 | # |
---|
21 | # $Id: e-adresse.pl 3 2007-10-18 16:20:19Z root $ |
---|
22 | # |
---|
23 | |
---|
24 | use strict ; |
---|
25 | use Test ; |
---|
26 | |
---|
27 | require 'test/A2P/Defaults.pm' ; |
---|
28 | |
---|
29 | use warnings FATAL => qw(void); |
---|
30 | |
---|
31 | BEGIN { |
---|
32 | plan |
---|
33 | tests => 7, |
---|
34 | onfail => sub { exit(1) } |
---|
35 | } |
---|
36 | |
---|
37 | $| = 1 ; |
---|
38 | |
---|
39 | $ENV{JOB} = "TEST-JOB-EADRESSE" ; |
---|
40 | |
---|
41 | my $script = "LANG=C EADRESSE_CONF=test perl e-adresse.pl" ; |
---|
42 | # We should start the script in each possible mode with a test file |
---|
43 | |
---|
44 | # A simple call must fail as script is expecting something to do |
---|
45 | ok system( $script); |
---|
46 | # A call with a bad file must fail, also if more than 2 args are given |
---|
47 | ok system( $script . ' test/e-adresse-good.xml' ); |
---|
48 | ok system( $script . ' test/e-adresse-good.xml test/e-adresse-a2p.xml' ); |
---|
49 | |
---|
50 | # A call with a right formatted file must return 0 |
---|
51 | my $mail = '/tmp/e-adresse.txt' ; |
---|
52 | unlink $mail if -s $mail ; |
---|
53 | ok ! system( $script . ' test/e-adresse-a2p.xml' ); |
---|
54 | ok -s $mail ; |
---|
55 | unlink $mail if -s $mail ; |
---|
56 | ok ! system( 'cat test/e-adresse-a2p.xml | ' . $script ); |
---|
57 | ok -s $mail ; |
---|