6 "github.com/mjl-/mox/imapclient"
9func TestExpunge(t *testing.T) {
10 defer mockUIDValidity()()
14 tc2 := startNoSwitchboard(t)
17 tc.client.Login("mjl@mox.example", password0)
18 tc.client.Select("inbox")
20 tc2.client.Login("mjl@mox.example", password0)
21 tc2.client.Select("inbox")
23 tc.transactf("bad", "expunge leftover") // Leftover data.
24 tc.transactf("ok", "expunge") // Nothing to remove though.
28 tc.client.Examine("inbox")
29 tc.transactf("no", "expunge") // Read-only.
30 tc.transactf("no", "uid expunge 1") // Read-only.
33 tc.client.Select("inbox")
34 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
35 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
36 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
37 tc.transactf("ok", "expunge") // Still nothing to remove.
40 tc.client.StoreFlagsAdd("1,3", true, `\Deleted`)
42 tc2.transactf("ok", "noop") // Drain.
44 tc.transactf("ok", "expunge")
45 tc.xuntagged(imapclient.UntaggedExpunge(1), imapclient.UntaggedExpunge(2))
47 tc2.transactf("ok", "noop") // Drain.
48 tc2.xuntagged(imapclient.UntaggedExpunge(1), imapclient.UntaggedExpunge(2))
50 tc.transactf("ok", "expunge") // Nothing to remove anymore.
53 // Only UID 2 is still left. We'll add 3 more. Getting us to UIDs 2,4,5,6.
54 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
55 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
56 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
58 tc.transactf("bad", "uid expunge") // Missing uid set.
59 tc.transactf("bad", "uid expunge 1 leftover") // Leftover data.
60 tc.transactf("bad", "uid expunge 1 leftover") // Leftover data.
62 tc.client.StoreFlagsAdd("1,2,4", true, `\Deleted`) // Marks UID 2,4,6 as deleted.
64 tc.transactf("ok", "uid expunge 1")
65 tc.xuntagged() // No match.
67 tc2.transactf("ok", "noop") // Drain.
69 tc.transactf("ok", "uid expunge 4:6") // Removes UID 4,6 at seqs 2,4.
70 tc.xuntagged(imapclient.UntaggedExpunge(2), imapclient.UntaggedExpunge(3))
72 tc2.transactf("ok", "noop")
73 tc.xuntagged(imapclient.UntaggedExpunge(2), imapclient.UntaggedExpunge(3))