| 1 |
doveadm -u "local" mailbox create --no-userdb-lookup "root.from" "root.from.child" "root.from.child2" "root.from.child.grandchild" |
| 2 |
doveadm -u "remote" mailbox create --no-userdb-lookup "root^sibbling" "root^sibbling^grandchild" "root2" |
| 3 |
|
| 4 |
for m in "root.from" "root.from.child" "root.from.child2" "root.from.child.grandchild" "INBOX"; do |
| 5 |
sample_message | deliver -u "local" -- -m "$m" |
| 6 |
done |
| 7 |
for m in "root^sibbling" "root^sibbling^grandchild" "root2" "INBOX"; do |
| 8 |
sample_message | deliver -u "remote" -- -m "$m" |
| 9 |
done |
| 10 |
|
| 11 |
interimap_init |
| 12 |
check_mailboxes_status "root.from" "root.from.child" "root.from.child2" "root.from.child.grandchild" \ |
| 13 |
"root.sibbling" "root.sibbling.grandchild" "root2" "INBOX" |
| 14 |
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.csv" <<-EOF |
| 15 |
.mode csv |
| 16 |
SELECT idx, hex(mailbox) |
| 17 |
FROM mailboxes |
| 18 |
ORDER BY idx |
| 19 |
EOF |
| 20 |
|
| 21 |
step_start "non-existent source (no-op)" |
| 22 |
interimap --rename "nonexistent" "root" || error "Renamed non-existent mailbox?" |
| 23 |
check_mailbox_list |
| 24 |
step_done |
| 25 |
|
| 26 |
step_start "\\NonExistent target (fail)" |
| 27 |
! interimap --rename "root2" "root" || error "Didn't abort on ALREADYEXISTS" |
| 28 |
grep -E "^local: ERROR: Couldn't rename mailbox root2: NO \[ALREADYEXISTS\] " <"$STDERR" |
| 29 |
check_mailbox_list |
| 30 |
step_done |
| 31 |
|
| 32 |
|
| 33 |
# rename 'root.from' to 'from.root', including inferiors |
| 34 |
step_start "existing source with inferiors" |
| 35 |
interimap --rename "root.from" "from.root" |
| 36 |
grep -Fx 'local: Renamed mailbox root.from to from.root' <"$STDERR" |
| 37 |
grep -Fx 'remote: Renamed mailbox root^from to from^root' <"$STDERR" |
| 38 |
grep -Fx 'database: Renamed mailbox root.from to from.root' <"$STDERR" |
| 39 |
|
| 40 |
check_mailbox_list |
| 41 |
check_mailboxes_status "from.root" "from.root.child" "from.root.child2" "from.root.child.grandchild" \ |
| 42 |
"root.sibbling" "root.sibbling.grandchild" "root2" "INBOX" |
| 43 |
|
| 44 |
before="$(printf "%s\\0%s" "root" "from" | xxd -u -ps)" |
| 45 |
after="$(printf "%s\\0%s" "from" "root" | xxd -u -ps)" |
| 46 |
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes2.csv" <<-EOF |
| 47 |
.mode csv |
| 48 |
SELECT idx, |
| 49 |
CASE |
| 50 |
WHEN mailbox = x'$after' OR hex(mailbox) LIKE '${after}00%' |
| 51 |
THEN '$before' || SUBSTR(hex(mailbox), $((${#after}+1))) |
| 52 |
ELSE hex(mailbox) |
| 53 |
END |
| 54 |
FROM mailboxes |
| 55 |
ORDER BY idx |
| 56 |
EOF |
| 57 |
diff -u --label="a/mailboxes.csv" --label="b/mailboxes.csv" \ |
| 58 |
"$TMPDIR/mailboxes.csv" "$TMPDIR/mailboxes2.csv" \ |
| 59 |
|| error "Mailbox list differs" |
| 60 |
step_done |
| 61 |
|
| 62 |
|
| 63 |
# rename \NonExistent root and check that its children move |
| 64 |
step_start "\\NonExistent source with inferiors" |
| 65 |
interimap --rename "root" "newroot" |
| 66 |
grep -Fq 'local: Renamed mailbox root to newroot' <"$STDERR" |
| 67 |
grep -Fq 'remote: Renamed mailbox root to newroot' <"$STDERR" |
| 68 |
grep -Fq 'database: Renamed mailbox root to newroot' <"$STDERR" |
| 69 |
|
| 70 |
check_mailbox_list |
| 71 |
check_mailboxes_status "from.root" "from.root.child" "from.root.child2" "from.root.child.grandchild" \ |
| 72 |
"newroot.sibbling" "newroot.sibbling.grandchild" "root2" "INBOX" |
| 73 |
|
| 74 |
before2="$(printf "%s" "root" | xxd -u -ps)" |
| 75 |
after2="$(printf "%s" "newroot" | xxd -u -ps)" |
| 76 |
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes3.csv" <<-EOF |
| 77 |
.mode csv |
| 78 |
SELECT idx, |
| 79 |
CASE |
| 80 |
WHEN mailbox = x'$after' OR hex(mailbox) LIKE '${after}00%' |
| 81 |
THEN '$before' || SUBSTR(hex(mailbox), $((${#after}+1))) |
| 82 |
WHEN hex(mailbox) LIKE '${after2}00%' |
| 83 |
THEN '$before2' || SUBSTR(hex(mailbox), $((${#after2}+1))) |
| 84 |
ELSE hex(mailbox) |
| 85 |
END |
| 86 |
FROM mailboxes |
| 87 |
ORDER BY idx |
| 88 |
EOF |
| 89 |
diff -u --label="a/mailboxes.csv" --label="b/mailboxes.csv" \ |
| 90 |
"$TMPDIR/mailboxes2.csv" "$TMPDIR/mailboxes3.csv" \ |
| 91 |
|| error "Mailbox list differs" |
| 92 |
step_done |
| 93 |
|
| 94 |
|
| 95 |
interimap |
| 96 |
check_mailbox_list |
| 97 |
check_mailboxes_status "from.root" "from.root.child" "from.root.child2" "from.root.child.grandchild" \ |
| 98 |
"newroot.sibbling" "newroot.sibbling.grandchild" "root2" "INBOX" |
| 99 |
|
| 100 |
# vim: set filetype=bash : |