6 "github.com/mjl-/mox/imapclient"
9func TestCopy(t *testing.T) {
13func TestCopyUIDOnly(t *testing.T) {
17func testCopy(t *testing.T, uidonly bool) {
18 defer mockUIDValidity()()
19 tc := start(t, uidonly)
22 tc2 := startNoSwitchboard(t, uidonly)
23 defer tc2.closeNoWait()
25 tc.login("mjl@mox.example", password0)
26 tc.client.Select("inbox")
28 tc2.login("mjl@mox.example", password0)
29 tc2.client.Select("Trash")
31 tc.transactf("bad", "copy") // Missing params.
32 tc.transactf("bad", "copy 1") // Missing params.
33 tc.transactf("bad", "copy 1 inbox ") // Leftover.
35 // Seqs 1,2 and UIDs 3,4.
36 tc.client.Append("inbox", makeAppend(exampleMsg))
37 tc.client.Append("inbox", makeAppend(exampleMsg))
38 tc.transactf("ok", `Uid Store 1:2 +Flags.Silent (\Deleted)`)
40 tc.client.Append("inbox", makeAppend(exampleMsg))
41 tc.client.Append("inbox", makeAppend(exampleMsg))
44 tc.transactf("ok", "uid copy 3:* Trash")
46 tc.transactf("no", "copy 1 nonexistent")
47 tc.xcodeWord("TRYCREATE")
48 tc.transactf("no", "copy 1 expungebox")
49 tc.xcodeWord("TRYCREATE")
51 tc.transactf("no", "copy 1 inbox") // Cannot copy to same mailbox.
53 tc2.transactf("ok", "noop") // Drain.
55 tc.transactf("ok", "copy 1:* Trash")
56 tc.xcode(mustParseCode("COPYUID 1 3:4 1:2"))
58 tc2.transactf("ok", "noop")
60 imapclient.UntaggedExists(2),
61 tc2.untaggedFetch(1, 1, imapclient.FetchFlags(nil)),
62 tc2.untaggedFetch(2, 2, imapclient.FetchFlags(nil)),
65 tc.transactf("no", "uid copy 1,2 Trash") // No match.
66 tc.transactf("ok", "uid copy 4,3 Trash")
67 tc.xcode(mustParseCode("COPYUID 1 3:4 3:4"))
68 tc2.transactf("ok", "noop")
70 imapclient.UntaggedExists(4),
71 tc2.untaggedFetch(3, 3, imapclient.FetchFlags(nil)),
72 tc2.untaggedFetch(4, 4, imapclient.FetchFlags(nil)),
75 tclimit := startArgs(t, uidonly, false, false, true, true, "limit")
77 tclimit.login("limit@mox.example", password0)
78 tclimit.client.Select("inbox")
79 // First message of 1 byte is within limits.
80 tclimit.transactf("ok", "append inbox (\\Seen Label1 $label2) \" 1-Jan-2022 10:10:00 +0100\" {1+}\r\nx")
81 tclimit.xuntagged(imapclient.UntaggedExists(1))
82 // Second message would take account past limit.
83 tclimit.transactf("no", "uid copy 1:* Trash")
84 tclimit.xcodeWord("OVERQUOTA")