aboutsummaryrefslogtreecommitdiffstats
path: root/tests/rename-simple/t
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rename-simple/t')
-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 :