1package imapserver
2
3import (
4 "testing"
5
6 "github.com/mjl-/mox/imapclient"
7)
8
9func TestSubscribe(t *testing.T) {
10 tc := start(t)
11 defer tc.close()
12
13 tc2 := startNoSwitchboard(t)
14 defer tc2.close()
15
16 tc.client.Login("mjl@mox.example", password0)
17 tc2.client.Login("mjl@mox.example", password0)
18
19 tc.transactf("bad", "subscribe") // Missing param.
20 tc.transactf("bad", "subscribe ") // Missing param.
21 tc.transactf("bad", "subscribe fine ") // Leftover data.
22
23 tc.transactf("ok", "subscribe a/b")
24 tc2.transactf("ok", "noop")
25 tc2.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "a/b"})
26 tc.transactf("ok", "subscribe a/b") // Already subscribed, which is fine.
27 tc2.transactf("ok", "noop")
28 tc2.xuntagged() // But no new changes.
29
30 tc.transactf("ok", `list (subscribed) "" "a*" return (subscribed)`)
31 tc.xuntagged(imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "a/b"})
32}
33