From 86f2705824a9c90512ff21b71bcf3728fc95c909 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Tue, 30 Dec 2014 22:57:07 +0100
Subject: [PATCH] testsuite: Added syntax checks for body test.

---
 Makefile.am                               |  1 +
 tests/extensions/body/errors.svtest       | 19 ++++++++++++
 tests/extensions/body/errors/syntax.sieve | 38 +++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 tests/extensions/body/errors.svtest
 create mode 100644 tests/extensions/body/errors/syntax.sieve

diff --git a/Makefile.am b/Makefile.am
index 2331e532a..128ea6544 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -106,6 +106,7 @@ test_cases = \
 	tests/extensions/imap4flags/flagstring.svtest \
 	tests/extensions/imap4flags/flagstore.svtest \
 	tests/extensions/body/basic.svtest \
+	tests/extensions/body/errors.svtest \
 	tests/extensions/body/raw.svtest \
 	tests/extensions/body/content.svtest \
 	tests/extensions/body/match-values.svtest \
diff --git a/tests/extensions/body/errors.svtest b/tests/extensions/body/errors.svtest
new file mode 100644
index 000000000..8db5657bf
--- /dev/null
+++ b/tests/extensions/body/errors.svtest
@@ -0,0 +1,19 @@
+require "vnd.dovecot.testsuite";
+
+require "relational";
+require "comparator-i;ascii-numeric";
+
+/*
+ * Invalid syntax
+ */
+
+test "Invalid Syntax" {
+        if test_script_compile "errors/syntax.sieve" {
+                test_fail "compile should have failed";
+        }
+
+        if not test_error :count "eq" :comparator "i;ascii-numeric" "12" {
+                test_fail "wrong number of errors reported";
+        }
+}
+
diff --git a/tests/extensions/body/errors/syntax.sieve b/tests/extensions/body/errors/syntax.sieve
new file mode 100644
index 000000000..8adf0efd6
--- /dev/null
+++ b/tests/extensions/body/errors/syntax.sieve
@@ -0,0 +1,38 @@
+require "body";
+
+# 1: No key list
+if body { }
+
+# 2: Number 
+if body 3 { }
+
+# OK: String
+if body "frop" { }
+
+# 3: To many arguments
+if body "frop" "friep" { }
+
+# 4: Unknown tag
+if body :frop { }
+
+# 5: Unknown tag with valid key
+if body :friep "frop" { }
+
+# 6: Content without argument
+if body :content { }
+
+# 7: Content without key argument
+if body :content "frop" { }
+
+# 8: Content with number argument
+if body :content 3 "frop" { }
+
+# 9: Content with unknown tag
+if body :content :frml "frop" { }
+
+# 10: Content with known tag
+if body :content :contains "frop" {  }
+
+# 11: Duplicate transform
+if body :content "frop" :raw "frop" {  }
+
-- 
GitLab