aboutsummaryrefslogtreecommitdiffstats
path: root/tests/list-select-opts
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/list-select-opts
parentb9da6cc7ecf71026d1023dc3354b820c7518426e (diff)
Refactor and improve test suite.
Diffstat (limited to 'tests/list-select-opts')
-rw-r--r--tests/list-select-opts/interimap.conf1
-rw-r--r--tests/list-select-opts/local.conf3
-rw-r--r--tests/list-select-opts/remote.conf3
-rw-r--r--tests/list-select-opts/t56
4 files changed, 63 insertions, 0 deletions
diff --git a/tests/list-select-opts/interimap.conf b/tests/list-select-opts/interimap.conf
new file mode 100644
index 0000000..2fa632d
--- /dev/null
+++ b/tests/list-select-opts/interimap.conf
@@ -0,0 +1 @@
+list-select-opts = SUBSCRIBED
diff --git a/tests/list-select-opts/local.conf b/tests/list-select-opts/local.conf
new file mode 100644
index 0000000..b56cc70
--- /dev/null
+++ b/tests/list-select-opts/local.conf
@@ -0,0 +1,3 @@
+namespace inbox {
+ separator = .
+}
diff --git a/tests/list-select-opts/remote.conf b/tests/list-select-opts/remote.conf
new file mode 100644
index 0000000..2d08a24
--- /dev/null
+++ b/tests/list-select-opts/remote.conf
@@ -0,0 +1,3 @@
+namespace inbox {
+ separator = ^
+}
diff --git a/tests/list-select-opts/t b/tests/list-select-opts/t
new file mode 100644
index 0000000..98acb43
--- /dev/null
+++ b/tests/list-select-opts/t
@@ -0,0 +1,56 @@
+doveadm -u "local" mailbox create -s "INBOX" "foo.bar"
+doveadm -u "remote" mailbox create -s "INBOX" "bar"
+
+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" "bar")"
+ sample_message | deliver -u "$u" -- -m "$m"
+done
+
+# create new unsubscribed mailboxes
+doveadm -u "local" mailbox create "foo"
+doveadm -u "remote" mailbox create "baz"
+
+for ((i = 0; i < 8; i++)); do
+ u="$(shuf -n1 -e "local" "remote")" # choose target at random
+ [ u="local" ] && m="foo" || m="baz"
+ sample_message | deliver -u "$u" -- -m "$m"
+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" "bar"
+
+# double check the unsubscribed mailboxes weren't copied
+! doveadm -u "remote" mailbox status uidvalidity "foo" || error
+! doveadm -u "local" mailbox status uidvalidity "baz" || error
+
+# reconcile when subcribed
+doveadm -u "local" mailbox subscribe "foo"
+doveadm -u "remote" mailbox subscribe "baz"
+
+interimap || error
+grep -Fx "database: Created mailbox foo" <"$STDERR" || error
+grep -Fx "database: Created mailbox baz" <"$STDERR" || error
+grep -Fx "local: Created mailbox baz" <"$STDERR" || error
+grep -Fx "remote: Created mailbox foo" <"$STDERR" || error
+
+check_mailbox_list
+check_mailboxes_status "INBOX" "foo" "foo.bar" "bar" "baz"
+
+# vim: set filetype=sh :