6 "github.com/mjl-/mox/imapclient"
9func TestDelete(t *testing.T) {
13 tc2 := startNoSwitchboard(t)
16 tc3 := startNoSwitchboard(t)
19 tc.client.Login("mjl@mox.example", "testtest")
20 tc2.client.Login("mjl@mox.example", "testtest")
21 tc3.client.Login("mjl@mox.example", "testtest")
23 tc.transactf("bad", "delete") // Missing mailbox.
24 tc.transactf("no", "delete inbox") // Cannot delete inbox.
25 tc.transactf("no", "delete nonexistent") // Cannot delete mailbox that does not exist.
26 tc.transactf("no", `delete "nonexistent"`) // Again, with quoted string syntax.
28 tc.client.Subscribe("x")
29 tc.transactf("no", "delete x") // Subscription does not mean there is a mailbox that can be deleted.
31 tc.client.Create("a/b")
32 tc2.transactf("ok", "noop") // Drain changes.
33 tc3.transactf("ok", "noop")
36 tc.transactf("no", "delete a") // Still has child.
37 tc.xcode("HASCHILDREN")
39 tc3.client.Enable("IMAP4rev2") // For \NonExistent support.
40 tc.transactf("ok", "delete a/b")
41 tc2.transactf("ok", "noop")
42 tc2.xuntagged() // No IMAP4rev2, no \NonExistent.
43 tc3.transactf("ok", "noop")
44 tc3.xuntagged(imapclient.UntaggedList{Flags: []string{`\NonExistent`}, Separator: '/', Mailbox: "a/b"})
46 tc.transactf("no", "delete a/b") // Already removed.
47 tc.transactf("ok", "delete a") // Parent can now be removed.
48 tc.transactf("ok", `list (subscribed) "" (a/b a) return (subscribed)`)
49 // Subscriptions still exist.
51 imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "a"},
52 imapclient.UntaggedList{Flags: []string{`\Subscribed`, `\NonExistent`}, Separator: '/', Mailbox: "a/b"},
55 // Let's try again with a message present.
56 tc.client.Create("msgs")
57 tc.client.Append("msgs", nil, nil, []byte(exampleMsg))
58 tc.transactf("ok", "delete msgs")
60 // Delete for inbox/* is allowed.
61 tc.client.Create("inbox/a")
62 tc.transactf("ok", "delete inbox/a")