7 "github.com/mjl-/mox/imapclient"
10func TestSelect(t *testing.T) {
11 testSelectExamine(t, false)
14func TestExamine(t *testing.T) {
15 testSelectExamine(t, true)
18// select and examine are pretty much the same. but examine opens readonly instead of readwrite.
19func testSelectExamine(t *testing.T, examine bool) {
20 defer mockUIDValidity()()
24 tc.client.Login("mjl@mox.example", password0)
27 okcode := "READ-WRITE"
33 uclosed := imapclient.UntaggedResult{Status: imapclient.OK, RespText: imapclient.RespText{Code: "CLOSED", More: "x"}}
34 flags := strings.Split(`\Seen \Answered \Flagged \Deleted \Draft $Forwarded $Junk $NotJunk $Phishing $MDNSent`, " ")
35 permflags := strings.Split(`\Seen \Answered \Flagged \Deleted \Draft $Forwarded $Junk $NotJunk $Phishing $MDNSent \*`, " ")
36 uflags := imapclient.UntaggedFlags(flags)
37 upermflags := imapclient.UntaggedResult{Status: imapclient.OK, RespText: imapclient.RespText{Code: "PERMANENTFLAGS", CodeArg: imapclient.CodeList{Code: "PERMANENTFLAGS", Args: permflags}, More: "x"}}
38 urecent := imapclient.UntaggedRecent(0)
39 uexists0 := imapclient.UntaggedExists(0)
40 uexists1 := imapclient.UntaggedExists(1)
41 uuidval1 := imapclient.UntaggedResult{Status: imapclient.OK, RespText: imapclient.RespText{Code: "UIDVALIDITY", CodeArg: imapclient.CodeUint{Code: "UIDVALIDITY", Num: 1}, More: "x"}}
42 uuidnext1 := imapclient.UntaggedResult{Status: imapclient.OK, RespText: imapclient.RespText{Code: "UIDNEXT", CodeArg: imapclient.CodeUint{Code: "UIDNEXT", Num: 1}, More: "x"}}
43 ulist := imapclient.UntaggedList{Separator: '/', Mailbox: "Inbox"}
44 uunseen := imapclient.UntaggedResult{Status: imapclient.OK, RespText: imapclient.RespText{Code: "UNSEEN", CodeArg: imapclient.CodeUint{Code: "UNSEEN", Num: 1}, More: "x"}}
45 uuidnext2 := imapclient.UntaggedResult{Status: imapclient.OK, RespText: imapclient.RespText{Code: "UIDNEXT", CodeArg: imapclient.CodeUint{Code: "UIDNEXT", Num: 2}, More: "x"}}
47 // Parameter required.
48 tc.transactf("bad", cmd)
50 // Mailbox does not exist.
51 tc.transactf("no", cmd+" bogus")
53 tc.transactf("ok", cmd+" inbox")
54 tc.xuntagged(uflags, upermflags, urecent, uexists0, uuidval1, uuidnext1, ulist)
57 tc.transactf("ok", cmd+` "inbox"`)
58 tc.xuntagged(uclosed, uflags, upermflags, urecent, uexists0, uuidval1, uuidnext1, ulist)
61 // Append a message. It will be reported as UNSEEN.
62 tc.client.Append("inbox", nil, nil, []byte(exampleMsg))
63 tc.transactf("ok", cmd+" inbox")
64 tc.xuntagged(uclosed, uflags, upermflags, urecent, uunseen, uexists1, uuidval1, uuidnext2, ulist)
67 // With imap4rev2, we no longer get untagged RECENT or untagged UNSEEN.
68 tc.client.Enable("imap4rev2")
69 tc.transactf("ok", cmd+" inbox")
70 tc.xuntagged(uclosed, uflags, upermflags, uexists1, uuidval1, uuidnext2, ulist)