mirror of
https://github.com/mjl-/mox.git
synced 2025-07-13 08:54:38 +03:00
fix the Status command on imapclient.Conn
it needs at least 1 attribute. also make types for those attributes, so its harder to get them wrong. nothing was using this function.
This commit is contained in:
@ -42,7 +42,7 @@ func testCondstoreQresync(t *testing.T, qresync bool) {
|
||||
// First some tests without any messages.
|
||||
|
||||
tc.transactf("ok", "Status inbox (Highestmodseq)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"HIGHESTMODSEQ": 1}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusHighestModSeq: 1}})
|
||||
|
||||
// No messages, no matches.
|
||||
tc.transactf("ok", "Uid Fetch 1:* (Flags) (Changedsince 12345)")
|
||||
@ -160,10 +160,10 @@ func testCondstoreQresync(t *testing.T, qresync bool) {
|
||||
|
||||
// Check highestmodseq for mailboxes.
|
||||
tc.transactf("ok", "Status inbox (highestmodseq)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"HIGHESTMODSEQ": clientModseq}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusHighestModSeq: clientModseq}})
|
||||
|
||||
tc.transactf("ok", "Status otherbox (highestmodseq)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "otherbox", Attrs: map[string]int64{"HIGHESTMODSEQ": 3}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "otherbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusHighestModSeq: 3}})
|
||||
|
||||
// Check highestmodseq when we select.
|
||||
tc.transactf("ok", "Examine otherbox")
|
||||
@ -297,7 +297,7 @@ func testCondstoreQresync(t *testing.T, qresync bool) {
|
||||
|
||||
// Again after expunge: status, select, conditional store/fetch/search
|
||||
tc.transactf("ok", "Status inbox (Highestmodseq Messages Unseen Deleted)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"MESSAGES": 4, "UNSEEN": 4, "DELETED": 0, "HIGHESTMODSEQ": clientModseq}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusMessages: 4, imapclient.StatusUnseen: 4, imapclient.StatusDeleted: 0, imapclient.StatusHighestModSeq: clientModseq}})
|
||||
|
||||
tc.transactf("ok", "Close")
|
||||
tc.transactf("ok", "Select inbox")
|
||||
|
@ -90,15 +90,15 @@ func TestListExtended(t *testing.T) {
|
||||
}
|
||||
|
||||
ustatus := func(name string) imapclient.UntaggedStatus {
|
||||
attrs := map[string]int64{
|
||||
"MESSAGES": 0,
|
||||
"UIDNEXT": 1,
|
||||
"UIDVALIDITY": int64(uidval(name)),
|
||||
"UNSEEN": 0,
|
||||
"DELETED": 0,
|
||||
"SIZE": 0,
|
||||
"RECENT": 0,
|
||||
"APPENDLIMIT": 0,
|
||||
attrs := map[imapclient.StatusAttr]int64{
|
||||
imapclient.StatusMessages: 0,
|
||||
imapclient.StatusUIDNext: 1,
|
||||
imapclient.StatusUIDValidity: int64(uidval(name)),
|
||||
imapclient.StatusUnseen: 0,
|
||||
imapclient.StatusDeleted: 0,
|
||||
imapclient.StatusSize: 0,
|
||||
imapclient.StatusRecent: 0,
|
||||
imapclient.StatusAppendLimit: 0,
|
||||
}
|
||||
return imapclient.UntaggedStatus{Mailbox: name, Attrs: attrs}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func TestQuota1(t *testing.T) {
|
||||
// Check that we get a DELETED-STORAGE status attribute with value 0, also if
|
||||
// messages are marked deleted. We don't go through the trouble.
|
||||
tc.transactf("ok", "status inbox (DELETED-STORAGE)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"DELETED-STORAGE": 0}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusDeletedStorage: 0}})
|
||||
|
||||
// tclimit does have a limit.
|
||||
tclimit := startArgs(t, false, false, true, true, "limit")
|
||||
@ -50,5 +50,5 @@ func TestQuota1(t *testing.T) {
|
||||
tclimit.xuntagged(imapclient.UntaggedQuota{Root: "", Resources: []imapclient.QuotaResource{{Name: imapclient.QuotaResourceStorage, Usage: 0, Limit: 1}}})
|
||||
|
||||
tclimit.transactf("ok", "status inbox (DELETED-STORAGE)")
|
||||
tclimit.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"DELETED-STORAGE": 0}})
|
||||
tclimit.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusDeletedStorage: 0}})
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ func DisabledTestReference(t *testing.T) {
|
||||
defer tc3.close()
|
||||
tc3.client.Login("mjl@mox.example", password0)
|
||||
tc3.transactf("ok", `list "" "inbox" return (status (messages))`)
|
||||
tc3.xuntagged(imapclient.UntaggedList{Separator: '/', Mailbox: "Inbox"}, imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"MESSAGES": 0}})
|
||||
tc3.xuntagged(imapclient.UntaggedList{Separator: '/', Mailbox: "Inbox"}, imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusMessages: 0}})
|
||||
|
||||
tc2.transactf("ok", "fetch 1 rfc822.size")
|
||||
tc.xuntagged(imapclient.UntaggedFetch{Seq: 1, Attrs: []imapclient.FetchAttr{imapclient.FetchRFC822Size(len(exampleMsg))}})
|
||||
|
@ -20,15 +20,50 @@ func TestStatus(t *testing.T) {
|
||||
tc.transactf("bad", "status inbox (unknown)") // Unknown attribute.
|
||||
|
||||
tc.transactf("ok", "status inbox (messages uidnext uidvalidity unseen deleted size recent appendlimit)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"MESSAGES": 0, "UIDVALIDITY": 1, "UIDNEXT": 1, "UNSEEN": 0, "DELETED": 0, "SIZE": 0, "RECENT": 0, "APPENDLIMIT": 0}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{
|
||||
Mailbox: "Inbox",
|
||||
Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusMessages: 0,
|
||||
imapclient.StatusUIDValidity: 1,
|
||||
imapclient.StatusUIDNext: 1,
|
||||
imapclient.StatusUnseen: 0,
|
||||
imapclient.StatusDeleted: 0,
|
||||
imapclient.StatusSize: 0,
|
||||
imapclient.StatusRecent: 0,
|
||||
imapclient.StatusAppendLimit: 0,
|
||||
},
|
||||
})
|
||||
|
||||
// Again, now with a message in the mailbox.
|
||||
tc.transactf("ok", "append inbox {4+}\r\ntest")
|
||||
tc.transactf("ok", "status inbox (messages uidnext uidvalidity unseen deleted size recent appendlimit)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"MESSAGES": 1, "UIDVALIDITY": 1, "UIDNEXT": 2, "UNSEEN": 1, "DELETED": 0, "SIZE": 4, "RECENT": 0, "APPENDLIMIT": 0}})
|
||||
|
||||
tc.xuntagged(imapclient.UntaggedStatus{
|
||||
Mailbox: "Inbox",
|
||||
Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusMessages: 1,
|
||||
imapclient.StatusUIDValidity: 1,
|
||||
imapclient.StatusUIDNext: 2,
|
||||
imapclient.StatusUnseen: 1,
|
||||
imapclient.StatusDeleted: 0,
|
||||
imapclient.StatusSize: 4,
|
||||
imapclient.StatusRecent: 0,
|
||||
imapclient.StatusAppendLimit: 0,
|
||||
},
|
||||
})
|
||||
|
||||
tc.client.Select("inbox")
|
||||
tc.client.StoreFlagsSet("1", true, `\Deleted`)
|
||||
tc.transactf("ok", "status inbox (messages uidnext uidvalidity unseen deleted size recent appendlimit)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"MESSAGES": 1, "UIDVALIDITY": 1, "UIDNEXT": 2, "UNSEEN": 1, "DELETED": 1, "SIZE": 4, "RECENT": 0, "APPENDLIMIT": 0}})
|
||||
tc.xuntagged(imapclient.UntaggedStatus{
|
||||
Mailbox: "Inbox",
|
||||
Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusMessages: 1,
|
||||
imapclient.StatusUIDValidity: 1,
|
||||
imapclient.StatusUIDNext: 2,
|
||||
imapclient.StatusUnseen: 1,
|
||||
imapclient.StatusDeleted: 1,
|
||||
imapclient.StatusSize: 4,
|
||||
imapclient.StatusRecent: 0,
|
||||
imapclient.StatusAppendLimit: 0,
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -22,5 +22,5 @@ func TestUnselect(t *testing.T) {
|
||||
tc.client.StoreFlagsAdd("1", true, `\Deleted`)
|
||||
tc.transactf("ok", "unselect")
|
||||
tc.transactf("ok", "status inbox (messages)")
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[string]int64{"MESSAGES": 1}}) // Message not removed.
|
||||
tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusMessages: 1}}) // Message not removed.
|
||||
}
|
||||
|
Reference in New Issue
Block a user