package main import ( "testing" ) // Fixture layout (testdata/mail/produktor.io): // // info/ cur: 2 messages, new: 1 message, .Sent/cur: 1 message // ano/ cur: 1 message // postmaster/ new: 1 message // postman/ cur: (empty) // andriy.oblivantsev/ (missing — like an account with no mail yet) func TestStatMaildirInfo(t *testing.T) { st, err := statMaildir("testdata/mail/produktor.io/info") if err != nil { t.Fatal(err) } if st.Messages != 3 { // INBOX: cur 2 + new 1 t.Errorf("Messages = %d, want 3", st.Messages) } if st.Total != 4 { // INBOX 3 + .Sent 1 t.Errorf("Total = %d, want 4", st.Total) } if st.Storage < 1 { t.Errorf("Storage = %d, want > 0", st.Storage) } if st.Newest.IsZero() { t.Error("Newest should be set") } } func TestStatMaildirEmptyMailbox(t *testing.T) { st, err := statMaildir("testdata/mail/produktor.io/postman") if err != nil { t.Fatal(err) } if st.Messages != 0 || st.Total != 0 || st.Storage != 0 { t.Errorf("postman should be empty, got %+v", st) } } func TestStatMaildirMissingRoot(t *testing.T) { // An account with no Maildir on disk yet must report zero, not fail. st, err := statMaildir("testdata/mail/produktor.io/andriy.oblivantsev") if err != nil { t.Fatal(err) } if st.Messages != 0 || st.Total != 0 || st.Storage != 0 { t.Errorf("missing mailbox should be zero, got %+v", st) } }