1package imapserver
2
3import (
4 "testing"
5
6 "github.com/mjl-/mox/imapclient"
7)
8
9func TestQuota1(t *testing.T) {
10 tc := start(t)
11 defer tc.close()
12
13 tc.client.Login("mjl@mox.example", password0)
14
15 // We don't implement setquota.
16 tc.transactf("bad", `setquota "" (STORAGE 123)`)
17
18 tc.transactf("bad", "getquotaroot") // Missing param.
19 tc.transactf("bad", "getquotaroot inbox bogus") // Too many params.
20
21 tc.transactf("bad", "getquota") // Missing param.
22 tc.transactf("bad", "getquota a b") // Too many params.
23
24 // tc does not have a limit.
25 tc.transactf("ok", "getquotaroot inbox")
26 tc.xuntagged(imapclient.UntaggedQuotaroot([]string{""}))
27
28 tc.transactf("no", "getquota bogusroot")
29 tc.transactf("ok", `getquota ""`)
30 tc.xuntagged()
31
32 // Check that we get a DELETED-STORAGE status attribute with value 0, also if
33 // messages are marked deleted. We don't go through the trouble.
34 tc.transactf("ok", "status inbox (DELETED-STORAGE)")
35 tc.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusDeletedStorage: 0}})
36
37 // tclimit does have a limit.
38 tclimit := startArgs(t, false, false, true, true, "limit")
39 defer tclimit.close()
40
41 tclimit.client.Login("limit@mox.example", password0)
42
43 tclimit.transactf("ok", "getquotaroot inbox")
44 tclimit.xuntagged(
45 imapclient.UntaggedQuotaroot([]string{""}),
46 imapclient.UntaggedQuota{Root: "", Resources: []imapclient.QuotaResource{{Name: imapclient.QuotaResourceStorage, Usage: 0, Limit: 1}}},
47 )
48
49 tclimit.transactf("ok", `getquota ""`)
50 tclimit.xuntagged(imapclient.UntaggedQuota{Root: "", Resources: []imapclient.QuotaResource{{Name: imapclient.QuotaResourceStorage, Usage: 0, Limit: 1}}})
51
52 tclimit.transactf("ok", "status inbox (DELETED-STORAGE)")
53 tclimit.xuntagged(imapclient.UntaggedStatus{Mailbox: "Inbox", Attrs: map[imapclient.StatusAttr]int64{imapclient.StatusDeletedStorage: 0}})
54}
55