7 "github.com/mjl-/mox/imapclient"
10func TestStore(t *testing.T) {
14 tc.client.Login("mjl@mox.example", password0)
15 tc.client.Enable("imap4rev2")
17 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
18 tc.client.Select("inbox")
20 uid1 := imapclient.FetchUID(1)
21 noflags := imapclient.FetchFlags(nil)
23 tc.transactf("ok", "store 1 flags.silent ()")
26 tc.transactf("ok", `store 1 flags ()`)
27 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, noflags}})
28 tc.transactf("ok", `fetch 1 flags`)
29 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, noflags}})
31 tc.transactf("ok", `store 1 flags.silent (\Seen)`)
33 tc.transactf("ok", `fetch 1 flags`)
34 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{`\Seen`}}})
36 tc.transactf("ok", `store 1 flags ($Junk)`)
37 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{`$Junk`}}})
38 tc.transactf("ok", `fetch 1 flags`)
39 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{`$Junk`}}})
41 tc.transactf("ok", `store 1 +flags ()`)
42 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{`$Junk`}}})
43 tc.transactf("ok", `store 1 +flags (\Deleted)`)
44 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{`\Deleted`, `$Junk`}}})
45 tc.transactf("ok", `fetch 1 flags`)
46 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{`\Deleted`, `$Junk`}}})
48 tc.transactf("ok", `store 1 -flags \Deleted $Junk`)
49 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, noflags}})
50 tc.transactf("ok", `fetch 1 flags`)
51 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, noflags}})
55 tc.transactf("ok", "uid store 1 flags ()")
56 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, noflags}})
58 tc.transactf("ok", "store 1 flags (new)") // New flag.
59 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{"new"}}})
60 tc.transactf("ok", "store 1 flags (new new a b c)") // Duplicates are ignored.
61 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{"a", "b", "c", "new"}}})
62 tc.transactf("ok", "store 1 +flags (new new c d e)")
63 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{"a", "b", "c", "d", "e", "new"}}})
64 tc.transactf("ok", "store 1 -flags (new new e a c)")
65 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{"b", "d"}}})
66 tc.transactf("ok", "store 1 flags ($Forwarded Different)")
67 tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{uid1, imapclient.FetchFlags{"$Forwarded", "different"}}})
69 tc.transactf("bad", "store") // Need numset, flags and args.
70 tc.transactf("bad", "store 1") // Need flags.
71 tc.transactf("bad", "store 1 +") // Need flags.
72 tc.transactf("bad", "store 1 -") // Need flags.
73 tc.transactf("bad", "store 1 flags ") // Need flags.
74 tc.transactf("bad", "store 1 flags ") // Need flags.
77 tc.transactf("ok", "examine inbox") // Open read-only.
79 // Flags are added to mailbox, not removed.
80 flags := strings.Split(`\Seen \Answered \Flagged \Deleted \Draft $Forwarded $Junk $NotJunk $Phishing $MDNSent a b c d different e new`, " ")
81 tc.xuntaggedOpt(false, imapclient.UntaggedFlags(flags))
83 tc.transactf("no", `store 1 flags ()`) // No permission to set flags.