aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ignore-mailbox
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-11-09 03:13:45 +0100
committerGuilhem Moulin <guilhem@fripost.org>2019-11-13 06:23:56 +0100
commit67440844c422ee30b31df9a46a7f99ac0e833add (patch)
tree989381e5b94d5939dafdd1e99c7db2ada95355ec /tests/ignore-mailbox
parentb9da6cc7ecf71026d1023dc3354b820c7518426e (diff)
Refactor and improve test suite.
Diffstat (limited to 'tests/ignore-mailbox')
-rw-r--r--tests/ignore-mailbox/interimap.conf1
-rw-r--r--tests/ignore-mailbox/local.conf3
-rw-r--r--tests/ignore-mailbox/remote.conf3
-rw-r--r--tests/ignore-mailbox/t62
4 files changed, 69 insertions, 0 deletions
diff --git a/tests/ignore-mailbox/interimap.conf b/tests/ignore-mailbox/interimap.conf
new file mode 100644
index 0000000..6168958
--- /dev/null
+++ b/tests/ignore-mailbox/interimap.conf
@@ -0,0 +1 @@
+ignore-mailbox = ^virtual(?:\x00|$)
diff --git a/tests/ignore-mailbox/local.conf b/tests/ignore-mailbox/local.conf
new file mode 100644
index 0000000..b56cc70
--- /dev/null
+++ b/tests/ignore-mailbox/local.conf
@@ -0,0 +1,3 @@
+namespace inbox {
+ separator = .
+}
diff --git a/tests/ignore-mailbox/remote.conf b/tests/ignore-mailbox/remote.conf
new file mode 100644
index 0000000..2d08a24
--- /dev/null
+++ b/tests/ignore-mailbox/remote.conf
@@ -0,0 +1,3 @@
+namespace inbox {
+ separator = ^
+}
diff --git a/tests/ignore-mailbox/t b/tests/ignore-mailbox/t
new file mode 100644
index 0000000..f90227c
--- /dev/null
+++ b/tests/ignore-mailbox/t
@@ -0,0 +1,62 @@
+doveadm -u "local" mailbox create "foo" -- "-virtual"
+doveadm -u "remote" mailbox create "bar" -- "virtual-"
+
+interimap_init
+check_mailbox_list
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.sql" <<-EOF
+ SELECT idx, mailbox FROM mailboxes ORDER BY idx
+EOF
+
+for ((i = 0; i < 16; i++)); do
+ u="$(shuf -n1 -e "local" "remote")" # choose target at random
+ m="$(shuf -n1 -e -- "INBOX" "foo" "bar")"
+ sample_message | deliver -u "$u" -- -m "$m"
+done
+
+# create new mailboxes matching 'ignore-mailbox'
+doveadm -u "local" mailbox create "virtual" "virtual.foo"
+doveadm -u "remote" mailbox create "virtual^bar"
+for n in $(seq 1 "$(shuf -n1 -i1-8)"); do
+ sample_message | deliver -u "local" -- -m "virtual"
+ sample_message | deliver -u "local" -- -m "virtual.foo"
+done
+for n in $(seq 1 "$(shuf -n1 -i1-8)"); do
+ sample_message | deliver -u "remote" -- -m "virtual^bar"
+done
+
+
+# no new mailbox should be created
+interimap || error
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes2.sql" <<-EOF
+ SELECT idx, mailbox FROM mailboxes ORDER BY idx
+EOF
+diff -u --label="a/mailboxes.sql" --label="b/mailboxes.sql" \
+ "$TMPDIR/mailboxes.sql" "$TMPDIR/mailboxes2.sql" || error "SQL dumps differ"
+
+check_mailboxes_status "INBOX" "foo" "bar"
+
+# double check the unsubscribed mailboxes weren't copied
+! doveadm -u "remote" mailbox status uidvalidity "virtual" || error
+! doveadm -u "remote" mailbox status uidvalidity "virtual^foo" || error
+! doveadm -u "local" mailbox status uidvalidity "virtual.bar" || error
+
+
+# ignored mailboxes are created when passed to the command line
+interimap "virtual" "virtual.bar" || error
+grep -Fx "database: Created mailbox virtual" <"$STDERR" || error
+grep -Fx "database: Created mailbox virtual.bar" <"$STDERR" || error
+grep -Fx "local: Created mailbox virtual.bar" <"$STDERR" || error
+grep -Fx "remote: Created mailbox virtual" <"$STDERR" || error
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.sql" <<-EOF
+ SELECT idx, mailbox FROM mailboxes
+ WHERE mailbox != x'$(printf "virtual" | xxd -ps)'
+ AND mailbox != x'$(printf "%s\\0%s" "virtual" "foo" | xxd -ps)'
+ ORDER BY idx
+EOF
+
+check_mailboxes_status "virtual" "virtual.bar" || error
+
+# vim: set filetype=sh :