blob: 6ebee9a90c5ab3aef12371a770379b733f448bad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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 :
|