1package imapserver
2
3import (
4 "testing"
5
6 "github.com/mjl-/mox/imapclient"
7)
8
9func TestLsub(t *testing.T) {
10 tc := start(t)
11 defer tc.close()
12
13 tc.client.Login("mjl@mox.example", "testtest")
14
15 tc.transactf("bad", "lsub") // Missing params.
16 tc.transactf("bad", `lsub ""`) // Missing param.
17 tc.transactf("bad", `lsub "" x `) // Leftover data.
18
19 tc.transactf("ok", `lsub "" x*`)
20 tc.xuntagged()
21
22 tc.transactf("ok", "create a/b/c")
23 tc.transactf("ok", `lsub "" a/*`)
24 tc.xuntagged(imapclient.UntaggedLsub{Separator: '/', Mailbox: "a/b"}, imapclient.UntaggedLsub{Separator: '/', Mailbox: "a/b/c"})
25
26 // ../rfc/3501:2394
27 tc.transactf("ok", "unsubscribe a")
28 tc.transactf("ok", "unsubscribe a/b")
29 tc.transactf("ok", `lsub "" a/%%`)
30 tc.xuntagged(imapclient.UntaggedLsub{Flags: []string{`\NoSelect`}, Separator: '/', Mailbox: "a/b"})
31
32 tc.transactf("ok", "unsubscribe a/b/c")
33 tc.transactf("ok", `lsub "" a/%%`)
34 tc.xuntagged()
35}
36