- admin/: Go stdlib-only HTTP viewer, lists accounts from config/postfix-accounts.cf with per-mailbox message counts (INBOX and total, same numbers doveadm reports) and storage; quota from dovecot-quotas.cf; Basic Auth from .env; offline tests vs fixtures (go test -race ./...) - compose: mail-admin service, build admin/Dockerfile, publishes 127.0.0.1:19945 / 172.17.0.1:19945; config and mail-data mounted :ro, no docker socket - NPM proxy host 66: location /admin/ -> 172.17.0.1:19945 - README: account admin section
39 lines
779 B
Go
39 lines
779 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseQuotas(t *testing.T) {
|
|
f, err := os.Open("testdata/quotas.cf")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer f.Close()
|
|
quotas, err := parseQuotas(f)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(quotas) != 2 {
|
|
t.Fatalf("got %d quotas, want 2", len(quotas))
|
|
}
|
|
if quotas["info@produktor.io"] != "500M" {
|
|
t.Errorf("info quota = %q, want 500M", quotas["info@produktor.io"])
|
|
}
|
|
if quotas["ano@produktor.io"] != "250M" {
|
|
t.Errorf("ano quota = %q, want 250M", quotas["ano@produktor.io"])
|
|
}
|
|
}
|
|
|
|
func TestParseQuotasEmpty(t *testing.T) {
|
|
quotas, err := parseQuotas(strings.NewReader("# no limits\n\n"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(quotas) != 0 {
|
|
t.Fatalf("got %d quotas, want 0", len(quotas))
|
|
}
|
|
}
|