Blame view

sieve/tests/relational.at 3.47 KB
1 2 3 4 5 6 7 8
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
9
# GNU Mailutils is distributed in the hope that it will be useful, but
10 11 12 13 14 15 16 17
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>.

m4_pushdef([MUT_SIEVE_MAILBOX],[relational.mbox])
18 19
m4_pushdef([MUT_SIEVE_OPTIONS],[--set ":mailbox:folder=`pwd`" dnl
 --set ":mailbox:mailbox-pattern=`pwd`/"'${user}'])
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

MUT_TESTCASE([relational address],[test relational address comparator i-ascii-numeric],
[
require [["relational", "comparator-i;ascii-numeric"]];

if address :count "ge" :comparator "i;ascii-numeric" [["to", "cc"] ["3"]]
  {
    discard;
  }
],[],[0],[],
[DISCARD on msg uid 1: marking as deleted
IMPLICIT KEEP on msg uid 2
IMPLICIT KEEP on msg uid 3
IMPLICIT KEEP on msg uid 4
IMPLICIT KEEP on msg uid 5
IMPLICIT KEEP on msg uid 6
IMPLICIT KEEP on msg uid 7
IMPLICIT KEEP on msg uid 8
DISCARD on msg uid 9: marking as deleted
])

MUT_TESTCASE([relational header],[test relational header comparator i-ascii-numeric],
[
require [["relational", "comparator-i;ascii-numeric"]];

if header :count "gt" [["received"]] [["2"]]
  {
    discard;
  }
],[],[0],[],
[IMPLICIT KEEP on msg uid 1
IMPLICIT KEEP on msg uid 2
IMPLICIT KEEP on msg uid 3
IMPLICIT KEEP on msg uid 4
IMPLICIT KEEP on msg uid 5
IMPLICIT KEEP on msg uid 6
IMPLICIT KEEP on msg uid 7
IMPLICIT KEEP on msg uid 8
DISCARD on msg uid 9: marking as deleted
])

61 62
m4_pushdef([FILEEXISTS],[test -f "$1" || echo "$1 missing"])

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
MUT_TESTCASE([relational big test],[test relational relational-hairy],
[
require [["relational", "comparator-i;ascii-numeric", "fileinto"]];

if header :value "lt" :comparator "i;ascii-numeric" [["x-priority"]] [["3"]]
  {
    fileinto "%Priority";
  }
elsif address :count "gt" :comparator "i;ascii-numeric" [["to"]] [["5"]]
  {
    # everything with more than 5 recipients in the "to" field
    # is considered SPAM
    fileinto "%SPAM";
  }
elsif address :value "gt" :all :comparator "i;ascii-casemap" [["from"]] [["M"]]
  {
    fileinto "%From_N-Z";
  }
else
  {
    fileinto "%From_A-M";
  }

if allof (address :count "eq" :comparator "i;ascii-numeric"
                  [["to", "cc"]] [["1"]] ,
          address :all :comparator "i;ascii-casemap"
                  [["to", "cc"]] [["me@foo.example.com.invalid"]])
  {
    fileinto "%Only_me";
  }
93 94 95 96 97 98 99 100
],
[
FILEEXISTS([From_A-M])
FILEEXISTS([From_N-Z])
FILEEXISTS([Priority])
FILEEXISTS([Only_me])
FILEEXISTS([SPAM])
],[0],[],
101 102 103 104 105 106 107 108 109 110 111
[FILEINTO on msg uid 1: delivering into %From_A-M
FILEINTO on msg uid 2: delivering into %From_N-Z
FILEINTO on msg uid 3: delivering into %Priority
FILEINTO on msg uid 4: delivering into %Priority
FILEINTO on msg uid 5: delivering into %Priority
FILEINTO on msg uid 6: delivering into %From_A-M
FILEINTO on msg uid 7: delivering into %From_A-M
FILEINTO on msg uid 8: delivering into %From_A-M
FILEINTO on msg uid 8: delivering into %Only_me
FILEINTO on msg uid 9: delivering into %SPAM
])
112
m4_popdef([FILEEXISTS])
113 114
m4_popdef([MUT_SIEVE_MAILBOX])
m4_popdef([MUT_SIEVE_OPTIONS])