aboutsummaryrefslogtreecommitdiffstats
path: root/tests/list-select-opts/t
blob: 30c3fe9a6044fb578d9746647d34883385f6e334 (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
doveadm -u "local"  mailbox create -s "INBOX" "foo.bar"
doveadm -u "remote" mailbox create -s "INBOX" "bar"

interimap_init
check_mailbox_list

sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.sql" <<-EOF
	SELECT idx, mailbox FROM mailboxes ORDER BY idx
EOF

for ((i = 0; i < 16; i++)); do
     u="$(shuf -n1 -e "local" "remote")" # choose target at random
     m="$(shuf -n1 -e -- "INBOX" "foo.bar" "bar")"
     sample_message | deliver -u "$u" -- -m "$m"
done

# create new unsubscribed mailboxes
doveadm -u "local"  mailbox create "foo"
doveadm -u "remote" mailbox create "baz"

for ((i = 0; i < 8; i++)); do
     u="$(shuf -n1 -e "local" "remote")" # choose target at random
     [ u="local" ] && m="foo" || m="baz"
     sample_message | deliver -u "$u" -- -m "$m"
done


# no new mailbox should be created
interimap || error

sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes2.sql" <<-EOF
	SELECT idx, mailbox FROM mailboxes ORDER BY idx
EOF
diff -u --label="a/mailboxes.sql" --label="b/mailboxes.sql" \
    "$TMPDIR/mailboxes.sql" "$TMPDIR/mailboxes2.sql" || error "SQL dumps differ"

check_mailboxes_status "INBOX" "foo.bar" "bar"

# double check the unsubscribed mailboxes weren't copied
! doveadm -u "remote" mailbox status uidvalidity "foo" || error
! doveadm -u "local"  mailbox status uidvalidity "baz" || error

# reconcile when subcribed
doveadm -u "local"  mailbox subscribe "foo"
doveadm -u "remote" mailbox subscribe "baz"

interimap || error
grep -Fx "database: Created mailbox foo" <"$STDERR" || error
grep -Fx "database: Created mailbox baz" <"$STDERR" || error
grep -Fx "local: Created mailbox baz"    <"$STDERR" || error
grep -Fx "remote: Created mailbox foo"   <"$STDERR" || error

check_mailbox_list
check_mailboxes_status "INBOX" "foo" "foo.bar" "bar" "baz"

# vim: set filetype=bash :