aboutsummaryrefslogtreecommitdiffstats
path: root/tests/02-delete/run
blob: f63c52c83991ee7ae9883a15edf945d6927abdd4 (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
62
63
64
65
66
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 :