6 "github.com/mjl-/mox/imapclient"
9func TestMove(t *testing.T) {
10 defer mockUIDValidity()()
14 tc2 := startNoSwitchboard(t)
17 tc3 := startNoSwitchboard(t)
20 tc.client.Login("mjl@mox.example", password0)
21 tc.client.Select("inbox")
23 tc2.client.Login("mjl@mox.example", password0)
24 tc2.client.Select("Trash")
26 tc3.client.Login("mjl@mox.example", password0)
27 tc3.client.Select("inbox")
29 tc.transactf("bad", "move") // Missing params.
30 tc.transactf("bad", "move 1") // Missing params.
31 tc.transactf("bad", "move 1 inbox ") // Leftover.
33 // Seqs 1,2 and UIDs 3,4.
34 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
35 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
36 tc.client.StoreFlagsSet("1:2", true, `\Deleted`)
38 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
39 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
42 tc.client.Examine("inbox")
43 tc.transactf("no", "move 1 Trash") // Opened readonly.
45 tc.client.Select("inbox")
47 tc.transactf("no", "move 1 nonexistent")
50 tc.transactf("no", "move 1 inbox") // Cannot move to same mailbox.
52 tc2.transactf("ok", "noop") // Drain.
53 tc3.transactf("ok", "noop") // Drain.
55 tc.transactf("ok", "move 1:* Trash")
56 ptr := func(v uint32) *uint32 { return &v }
58 imapclient.UntaggedResult{Status: "OK", RespText: imapclient.RespText{Code: "COPYUID", CodeArg: imapclient.CodeCopyUID{DestUIDValidity: 1, From: []imapclient.NumRange{{First: 3, Last: ptr(4)}}, To: []imapclient.NumRange{{First: 1, Last: ptr(2)}}}, More: "moved"}},
59 imapclient.UntaggedExpunge(1),
60 imapclient.UntaggedExpunge(1),
62 tc2.transactf("ok", "noop")
64 imapclient.UntaggedExists(2),
65 imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{imapclient.FetchUID(1), imapclient.FetchFlags(nil)}},
66 imapclient.UntaggedFetch{Seq: 2, Attrs: []imapclient.FetchAttr{imapclient.FetchUID(2), imapclient.FetchFlags(nil)}},
68 tc3.transactf("ok", "noop")
69 tc3.xuntagged(imapclient.UntaggedExpunge(1), imapclient.UntaggedExpunge(1))
72 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
73 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
74 tc2.transactf("ok", "noop") // Drain.
75 tc3.transactf("ok", "noop") // Drain.
77 tc.transactf("no", "uid move 1:4 Trash") // No match.
78 tc.transactf("ok", "uid move 6:5 Trash")
80 imapclient.UntaggedResult{Status: "OK", RespText: imapclient.RespText{Code: "COPYUID", CodeArg: imapclient.CodeCopyUID{DestUIDValidity: 1, From: []imapclient.NumRange{{First: 5, Last: ptr(6)}}, To: []imapclient.NumRange{{First: 3, Last: ptr(4)}}}, More: "moved"}},
81 imapclient.UntaggedExpunge(1),
82 imapclient.UntaggedExpunge(1),
84 tc2.transactf("ok", "noop")
86 imapclient.UntaggedExists(4),
87 imapclient.UntaggedFetch{Seq: 3, Attrs: []imapclient.FetchAttr{imapclient.FetchUID(3), imapclient.FetchFlags(nil)}},
88 imapclient.UntaggedFetch{Seq: 4, Attrs: []imapclient.FetchAttr{imapclient.FetchUID(4), imapclient.FetchFlags(nil)}},
90 tc3.transactf("ok", "noop")
91 tc3.xuntagged(imapclient.UntaggedExpunge(1), imapclient.UntaggedExpunge(1))