Skip to content
Snippets Groups Projects
Commit a8380918 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Include: added various tests to the testsuite.

parent 89baff27
No related branches found
No related tags found
No related merge requests found
Showing
with 120 additions and 0 deletions
...@@ -56,6 +56,8 @@ test_cases = \ ...@@ -56,6 +56,8 @@ test_cases = \
tests/extensions/include/errors.svtest \ tests/extensions/include/errors.svtest \
tests/extensions/include/variables.svtest \ tests/extensions/include/variables.svtest \
tests/extensions/include/once.svtest \ tests/extensions/include/once.svtest \
tests/extensions/include/twice.svtest \
tests/extensions/include/rfc.svtest \
tests/extensions/imap4flags/basic.svtest \ tests/extensions/imap4flags/basic.svtest \
tests/extensions/imap4flags/hasflag.svtest \ tests/extensions/imap4flags/hasflag.svtest \
tests/extensions/imap4flags/errors.svtest \ tests/extensions/imap4flags/errors.svtest \
......
require ["reject"];
if anyof (header :contains "Subject" "$$",
header :contains "Subject" "Make money")
{
reject "Not wanted";
}
if header :is "From" "boss@example.com"
{
keep;
}
elsif header :is "From" "ceo@example.com"
{
keep;
}
require ["fileinto"];
if header :is "Sender" "owner-ietf-mta-filters@imc.org"
{
fileinto "lists.sieve";
}
elsif header :is "Sender" "owner-ietf-imapext@imc.org"
{
fileinto "lists.imapext";
}
require ["reject"];
if header :contains "Subject" "XXXX"
{
reject "Not wanted";
}
elsif header :is "From" "money@example.com"
{
reject "Not wanted";
}
require ["variables", "include"];
global ["test", "test_mailbox"];
if header :contains "Subject" "${test}"
{
set "test_mailbox" "spam-${test}";
}
require "include";
require "variables";
global "result";
set "result" "${result} TWO";
require "include";
require "variables";
global "result";
set "result" "${result} THREE";
include "twice-1.sieve";
require ["include"];
include :personal "rfc-ex1-always_allow";
include :global "rfc-ex1-spam_tests";
include :personal "rfc-ex1-spam_tests";
include :personal "rfc-ex1-mailing_lists";
require ["variables", "include", "relational", "fileinto"];
global "test";
global "test-mailbox";
# The included script may contain repetitive code that is
# effectively a subroutine that can be factored out.
set "test" "$$";
include "rfc-ex2-spam_filter_script";
set "test" "Make money";
include "rfc-ex2-spam_filter_script";
# Message will be filed according to the test that matched last.
if string :count "eq" "${test_mailbox}" "1"
{
fileinto "INBOX${test_mailbox}";
stop;
}
# If nothing matched, the message is implicitly kept.
require "vnd.dovecot.testsuite";
test "RFC example 1" {
if not test_script_compile "rfc-ex1-default.sieve" {
test_fail "failed to compile sieve script";
}
}
test "RFC example 2" {
if not test_script_compile "rfc-ex2-default.sieve" {
test_fail "failed to compile sieve script";
}
}
require "vnd.dovecot.testsuite";
require "include";
require "variables";
global "result";
set "result" "ONE";
test "Twice included" {
include "twice-1";
include "twice-2";
if string "${result}" "ONE TWO THREE" {
test_fail "duplicate include failed";
}
if not string "${result}" "ONE TWO THREE TWO" {
test_fail "unexpected result: ${result}";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.