aboutsummaryrefslogtreecommitdiffstats
path: root/tests/rename-simple
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-11-13 06:24:07 +0100
committerGuilhem Moulin <guilhem@fripost.org>2019-11-13 06:24:07 +0100
commitc6bbdd8aa697b2d42be1ac0839189da32d437a8f (patch)
treecd1b8d19d99557fbebe33344d0d23f6ac826da57 /tests/rename-simple
parent87d947df1b837514a0f1efa3bc36b58088bd2564 (diff)
parentdac4ab1c9306bf2035bc1547d2ed27ab09850120 (diff)
Merge branch 'master' into debian
Diffstat (limited to 'tests/rename-simple')
-rw-r--r--tests/rename-simple/t61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/rename-simple/t b/tests/rename-simple/t
new file mode 100644
index 0000000..6ebee9a
--- /dev/null
+++ b/tests/rename-simple/t
@@ -0,0 +1,61 @@
+doveadm -u "local" mailbox create "foo"
+
+sample_message | deliver -u "local" -- -m "INBOX"
+sample_message | deliver -u "remote" -- -m "INBOX"
+sample_message | deliver -u "remote" -- -m "foo"
+
+interimap_init
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.csv" <<-EOF
+ .mode csv
+ SELECT idx, hex(mailbox)
+ FROM mailboxes
+ ORDER BY idx
+EOF
+
+step_start "non-existent source (no-op)"
+interimap --rename "nonexistent" "bar" || error "Rename non-existent mailbox?"
+check_mailbox_list
+step_done
+
+step_start "existing target (fail)"
+! interimap --rename "nonexistent" "foo" || error "Overwrote target?"
+grep -Fx "local: ERROR: Mailbox foo exists. Run \`interimap --target=local --delete foo\` to delete." <"$STDERR" || error
+check_mailbox_list
+step_done
+
+step_start "INBOX"
+interimap --rename "INBOX" "baz" || error
+check_mailbox_list
+step_done
+
+step_start "\\Noinferiors mailbox"
+interimap --rename "foo" "bar" || error
+check_mailbox_list
+
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes2.csv" <<-EOF
+ .mode csv
+ SELECT idx,
+ CASE
+ WHEN mailbox = x'$(printf "baz" | xxd -u -ps)'
+ THEN '$(printf "%s" "INBOX" | xxd -u -ps)'
+ WHEN mailbox = x'$(printf "bar" | xxd -u -ps)'
+ THEN '$(printf "%s" "foo" | xxd -u -ps)'
+ ELSE hex(mailbox)
+ END
+ FROM mailboxes
+ ORDER BY idx
+EOF
+diff -u --label="a/mailboxes.csv" --label="b/mailboxes.csv" \
+ "$TMPDIR/mailboxes.csv" "$TMPDIR/mailboxes2.csv" \
+ || error "Mailbox list differs"
+step_done
+
+interimap
+# recreated after renaming
+grep -Fx "database: Created mailbox INBOX" <"$STDERR"
+
+check_mailbox_list
+check_mailboxes_status "INBOX" "bar" "baz"
+
+# vim: set filetype=sh :