aboutsummaryrefslogtreecommitdiffstats
path: root/tests/03-sync-mailbox-list
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-05-27 00:40:24 +0200
committerGuilhem Moulin <guilhem@fripost.org>2019-05-27 00:40:24 +0200
commite86590ad6858d0d597278393b8de2923dfed4084 (patch)
treefae8916cc9a81107460df6af0baa26af6d2e0727 /tests/03-sync-mailbox-list
parent6b9e183ea2abbe5137c7551eb8c5184eea51571e (diff)
parent8e379c62a48d68cd5ab2a32c6fc9244b1ae94084 (diff)
Merge branch 'master' into HEAD
Diffstat (limited to 'tests/03-sync-mailbox-list')
-rw-r--r--tests/03-sync-mailbox-list/local.conf6
-rw-r--r--tests/03-sync-mailbox-list/remote.conf6
-rw-r--r--tests/03-sync-mailbox-list/run73
3 files changed, 85 insertions, 0 deletions
diff --git a/tests/03-sync-mailbox-list/local.conf b/tests/03-sync-mailbox-list/local.conf
new file mode 100644
index 0000000..93497d9
--- /dev/null
+++ b/tests/03-sync-mailbox-list/local.conf
@@ -0,0 +1,6 @@
+namespace inbox {
+ separator = .
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/03-sync-mailbox-list/remote.conf b/tests/03-sync-mailbox-list/remote.conf
new file mode 100644
index 0000000..352cdd4
--- /dev/null
+++ b/tests/03-sync-mailbox-list/remote.conf
@@ -0,0 +1,6 @@
+namespace inbox {
+ separator = ~
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/03-sync-mailbox-list/run b/tests/03-sync-mailbox-list/run
new file mode 100644
index 0000000..e9fda06
--- /dev/null
+++ b/tests/03-sync-mailbox-list/run
@@ -0,0 +1,73 @@
+# pre-create some mailboxes and susbscribe to some
+# foo: present on both, subscribed to both
+# bar: present on both, subscribed to local only
+# baz: present on both, subscribed to remote only
+# foo.bar: present on local only
+# foo.baz: present on remote only
+doveadm -u "local" mailbox create "foo" "bar" "baz" "foo.bar" "fo!o [b*a%r]"
+doveadm -u "local" mailbox subscribe "foo" "bar"
+doveadm -u "remote" mailbox create "foo" "bar" "baz" "foo~baz" "foo]bar"
+doveadm -u "remote" mailbox subscribe "foo" "baz"
+
+interimap
+xgrep -Fx "local: Subscribe to baz" <"$STDERR"
+xgrep -Fx "remote: Subscribe to bar" <"$STDERR"
+xgrep -Fx "local: Created mailbox foo.baz" <"$STDERR"
+xgrep -Fx "remote: Created mailbox foo~bar" <"$STDERR"
+
+# check syncing
+check_mailbox_list
+check_mailboxes_status "foo" "bar" "baz" "foo.bar" "foo.baz" "INBOX" "fo!o [b*a%r]" "foo]bar"
+check_mailbox_list -s
+
+
+# delete a mailbox one server and verify that synchronization fails as it's still in the database
+doveadm -u "remote" mailbox delete "foo~baz"
+! interimap
+xgrep -Fx 'database: ERROR: Mailbox foo.baz exists. Run `interimap --target=database --delete foo.baz` to delete.' <"$STDERR"
+interimap --target="database" --delete "foo.baz"
+xgrep -Fx 'database: Removed mailbox foo.baz' <"$STDERR"
+interimap # create again
+xgrep -Fx 'database: Created mailbox foo.baz' <"$STDERR"
+xgrep -Fx 'remote: Created mailbox foo~baz' <"$STDERR"
+
+doveadm -u "local" mailbox delete "foo.bar"
+! interimap
+xgrep -Fx 'database: ERROR: Mailbox foo.bar exists. Run `interimap --target=database --delete foo.bar` to delete.' <"$STDERR"
+interimap --target="database" --delete "foo.bar"
+xgrep -Fx 'database: Removed mailbox foo.bar' <"$STDERR"
+interimap
+xgrep -Fx 'database: Created mailbox foo.bar' <"$STDERR"
+xgrep -Fx 'local: Created mailbox foo.bar' <"$STDERR"
+
+check_mailbox_list
+check_mailboxes_status "foo" "bar" "baz" "foo.bar" "foo.baz" "INBOX" "fo!o [b*a%r]" "foo]bar"
+check_mailbox_list -s
+
+
+# (un)subscribe from some mailboxes, including a non-existent one
+doveadm -u "local" mailbox unsubscribe "foo"
+doveadm -u "remote" mailbox unsubscribe "bar"
+doveadm -u "local" mailbox subscribe "foo.bar" "foo.nonexistent" "foo.baz"
+doveadm -u "remote" mailbox subscribe "foo~bar" "bar~nonexistent"
+
+interimap
+xgrep -Fx 'remote: Unsubscribe to foo' <"$STDERR"
+xgrep -Fx 'local: Unsubscribe to bar' <"$STDERR"
+xgrep -Fx 'remote: Subscribe to foo~baz' <"$STDERR"
+check_mailbox_list
+check_mailbox_list -s $(doveadm -u "local" mailbox list) # exclude "foo.nonexistent" and "bar~nonexistent"
+
+# check that "baz", "foo.bar" and "foo.baz" are the only subscribed mailboxes
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/count" <<-EOF
+ SELECT COUNT(*)
+ FROM mailboxes
+ WHERE subscribed <> (mailbox IN (
+ x'$(printf "%s" "baz" | xxd -ps)',
+ x'$(printf "%s\\0%s" "foo" "bar" | xxd -ps)',
+ x'$(printf "%s\\0%s" "foo" "baz" | xxd -ps)'
+ ))
+EOF
+[ $(< "$TMPDIR/count") -eq 0 ]
+
+# vim: set filetype=sh :