aboutsummaryrefslogtreecommitdiffstats
path: root/tests/02-delete
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/02-delete
parent6b9e183ea2abbe5137c7551eb8c5184eea51571e (diff)
parent8e379c62a48d68cd5ab2a32c6fc9244b1ae94084 (diff)
Merge branch 'master' into HEAD
Diffstat (limited to 'tests/02-delete')
-rw-r--r--tests/02-delete/local.conf6
-rw-r--r--tests/02-delete/remote.conf6
-rw-r--r--tests/02-delete/run67
3 files changed, 79 insertions, 0 deletions
diff --git a/tests/02-delete/local.conf b/tests/02-delete/local.conf
new file mode 100644
index 0000000..93497d9
--- /dev/null
+++ b/tests/02-delete/local.conf
@@ -0,0 +1,6 @@
+namespace inbox {
+ separator = .
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/02-delete/remote.conf b/tests/02-delete/remote.conf
new file mode 100644
index 0000000..cc6781d
--- /dev/null
+++ b/tests/02-delete/remote.conf
@@ -0,0 +1,6 @@
+namespace inbox {
+ separator = ^
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/02-delete/run b/tests/02-delete/run
new file mode 100644
index 0000000..f63c52c
--- /dev/null
+++ b/tests/02-delete/run
@@ -0,0 +1,67 @@
+doveadm -u "local" mailbox create "foo.bar" "foo.bar.baz"
+
+for m in "foo.bar" "foo.bar.baz" "INBOX"; do
+ sample_message | deliver -u "local" -- -m "$m"
+done
+
+interimap
+check_mailbox_list
+check_mailboxes_status "foo.bar" "foo.bar.baz" "INBOX"
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/dump.sql" <<-EOF
+ .dump
+EOF
+
+# delete non-existent mailbox is a no-op
+interimap --target="local,remote" --target="database" --delete "nonexistent"
+
+check_mailbox_list
+check_mailboxes_status "foo.bar" "foo.bar.baz" "INBOX"
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/dump2.sql" <<-EOF
+ .dump
+EOF
+diff -u --label="a/dump.sql" --label="b/dump.sql" \
+ "$TMPDIR/dump.sql" "$TMPDIR/dump2.sql"
+
+# foo.bar will become \NoSelect in local, per RFC 3501: "It is permitted
+# to delete a name that has inferior hierarchical names and does not
+# have the \Noselect mailbox name attribute. In this case, all messages
+# in that mailbox are removed, and the name will acquire the \Noselect
+# mailbox name attribute."
+interimap --target="local" --delete "foo.bar"
+
+check_mailbox_list
+check_mailboxes_status "foo.bar.baz" "INBOX"
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/dump2.sql" <<-EOF
+ .dump
+EOF
+diff -u --label="a/dump.sql" --label="b/dump.sql" "$TMPDIR/dump.sql" "$TMPDIR/dump2.sql"
+
+! doveadm -u "local" mailbox status uidvalidity "foo.bar" # gone
+ doveadm -u "remote" mailbox status uidvalidity "foo^bar"
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.csv" <<-EOF
+ SELECT idx, mailbox
+ FROM mailboxes
+ WHERE mailbox != x'$(printf "%s\\0%s" "foo" "bar" | xxd -ps)'
+EOF
+
+
+# now delete from the remote server and the database
+interimap --delete "foo.bar"
+
+! doveadm -u "local" mailbox status uidvalidity "foo.bar"
+! doveadm -u "remote" mailbox status uidvalidity "foo^bar"
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes2.csv" <<-EOF
+ SELECT idx, mailbox
+ FROM mailboxes
+ WHERE mailbox != x'$(printf "%s\\0%s" "foo" "bar" | xxd -ps)'
+EOF
+diff -u --label="a/mailboxes.csv" --label="b/mailboxes.csv" \
+ "$TMPDIR/mailboxes.csv" "$TMPDIR/mailboxes2.csv"
+
+check_mailbox_list
+check_mailboxes_status "foo.bar.baz" "INBOX"
+
+# vim: set filetype=sh :