Replace hand-rolled IMAP with go-imap
This commit is contained in:
parent
21aa6e39e1
commit
253435d87f
7 changed files with 449 additions and 346 deletions
26
backend/04-imap-source_test.go
Normal file
26
backend/04-imap-source_test.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/emersion/go-imap/v2"
|
||||
)
|
||||
|
||||
func TestSanitizeIMAPFlagsDropsRecentAndWildcard(t *testing.T) {
|
||||
got := sanitizeIMAPFlags([]imap.Flag{imap.FlagSeen, imap.Flag(`\Recent`), imap.FlagWildcard, imap.FlagAnswered})
|
||||
if len(got) != 2 || got[0] != imap.FlagSeen || got[1] != imap.FlagAnswered {
|
||||
t.Fatalf("sanitizeIMAPFlags returned %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessageIDFallsBackToBodyHash(t *testing.T) {
|
||||
body := []byte("From: a@example.com\r\nSubject: Test\r\n\r\nBody")
|
||||
id := messageID(body)
|
||||
if !strings.HasPrefix(id, "sha256:") {
|
||||
t.Fatalf("expected sha256 fallback, got %q", id)
|
||||
}
|
||||
if id != messageID(body) {
|
||||
t.Fatal("messageID hash fallback is not stable")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue