From cb916ccabf14808733c78a00844f2901e3ead394 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Thu, 11 Jun 2020 21:26:56 +0200
Subject: [PATCH] tests: compile: Add tests for fileinto command compile
 errors.

---
 tests/compile/errors.svtest         | 14 +++++++++++
 tests/compile/errors/fileinto.sieve | 38 +++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 tests/compile/errors/fileinto.sieve

diff --git a/tests/compile/errors.svtest b/tests/compile/errors.svtest
index a5aa212dc..f17ea3f17 100644
--- a/tests/compile/errors.svtest
+++ b/tests/compile/errors.svtest
@@ -242,6 +242,20 @@ test "Keep errors (FIXME: count only)" {
 	}
 }
 
+/*
+ * Fileinto command
+ */
+
+test "Fileinto errors (FIXME: count only)" {
+	if test_script_compile "errors/fileinto.sieve" {
+		test_fail "compile should have failed.";
+	}
+
+	if not test_error :count "eq" :comparator "i;ascii-numeric" "10" {
+		test_fail "wrong number of errors reported";
+	}
+}
+
 /*
  * COMPARATOR errors
  */
diff --git a/tests/compile/errors/fileinto.sieve b/tests/compile/errors/fileinto.sieve
new file mode 100644
index 000000000..0598557dc
--- /dev/null
+++ b/tests/compile/errors/fileinto.sieve
@@ -0,0 +1,38 @@
+require "fileinto";
+require "encoded-character";
+
+/*
+ * Fileinto errors
+ *
+ * Total erors: 9 (+1 = 10)
+ */
+
+# Missing string argument
+fileinto;
+
+# Spurious test
+fileinto true;
+
+# Spurious test
+fileinto "Frop" true;
+
+# Spurious number argument
+fileinto 33;
+
+# Spurious tag argument
+fileinto :frop;
+
+# Spurious additional string argument
+fileinto "Frop" "Friep";
+
+# Spurious additional number argument
+fileinto "Frop" 123;
+
+# Spurious additional tag argument
+fileinto "Frop" :frop;
+
+# Bad mailbox name
+fileinto "${hex:ff}rop";
+
+# Not an error
+fileinto "Frop";
-- 
GitLab