7 "github.com/mjl-/mox/imapclient"
10func TestStore(t *testing.T) {
14func TestStoreUIDOnly(t *testing.T) {
18func testStore(t *testing.T, uidonly bool) {
19 tc := start(t, uidonly)
22 tc.login("mjl@mox.example", password0)
23 tc.client.Enable(imapclient.CapIMAP4rev2)
25 tc.client.Append("inbox", makeAppend(exampleMsg))
26 tc.client.Select("inbox")
28 noflags := imapclient.FetchFlags(nil)
31 tc.transactf("ok", "store 1 flags.silent ()")
35 tc.transactf("ok", `uid store 1 flags ()`)
36 tc.xuntagged(tc.untaggedFetch(1, 1, noflags))
37 tc.transactf("ok", `uid fetch 1 flags`)
38 tc.xuntagged(tc.untaggedFetch(1, 1, noflags))
40 tc.transactf("ok", `uid store 1 flags.silent (\Seen)`)
42 tc.transactf("ok", `uid fetch 1 flags`)
43 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{`\Seen`}))
45 tc.transactf("ok", `uid store 1 flags ($Junk)`)
46 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{`$Junk`}))
47 tc.transactf("ok", `uid fetch 1 flags`)
48 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{`$Junk`}))
50 tc.transactf("ok", `uid store 1 +flags ()`)
51 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{`$Junk`}))
52 tc.transactf("ok", `uid store 1 +flags (\Deleted)`)
53 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{`\Deleted`, `$Junk`}))
54 tc.transactf("ok", `uid fetch 1 flags`)
55 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{`\Deleted`, `$Junk`}))
57 tc.transactf("ok", `uid store 1 -flags \Deleted $Junk`)
58 tc.xuntagged(tc.untaggedFetch(1, 1, noflags))
59 tc.transactf("ok", `uid fetch 1 flags`)
60 tc.xuntagged(tc.untaggedFetch(1, 1, noflags))
66 tc.transactf("ok", "uid store 1 flags ()")
67 tc.xuntagged(tc.untaggedFetch(1, 1, noflags))
69 tc.transactf("ok", "uid store 1 flags (new)") // New flag.
70 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{"new"}))
71 tc.transactf("ok", "uid store 1 flags (new new a b c)") // Duplicates are ignored.
72 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{"a", "b", "c", "new"}))
73 tc.transactf("ok", "uid store 1 +flags (new new c d e)")
74 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{"a", "b", "c", "d", "e", "new"}))
75 tc.transactf("ok", "uid store 1 -flags (new new e a c)")
76 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{"b", "d"}))
77 tc.transactf("ok", "uid store 1 flags ($Forwarded Different)")
78 tc.xuntagged(tc.untaggedFetch(1, 1, imapclient.FetchFlags{"$Forwarded", "different"}))
80 tc.transactf("bad", "store") // Need numset, flags and args.
81 tc.transactf("bad", "store 1") // Need flags.
82 tc.transactf("bad", "store 1 +") // Need flags.
83 tc.transactf("bad", "store 1 -") // Need flags.
84 tc.transactf("bad", "store 1 flags ") // Need flags.
85 tc.transactf("bad", "store 1 flags ") // Need flags.
88 tc.transactf("ok", "examine inbox") // Open read-only.
90 // Flags are added to mailbox, not removed.
91 flags := strings.Split(`\Seen \Answered \Flagged \Deleted \Draft $Forwarded $Junk $NotJunk $Phishing $MDNSent a b c d different e new`, " ")
92 tc.xuntaggedOpt(false, imapclient.UntaggedFlags(flags))
94 tc.transactf("no", `uid store 1 flags ()`) // No permission to set flags.