ultisuite-backend/internal/mail/threading/threading_test.go
R3D347HR4Y 95196f7777 Add mail attachment and draft management features
- Introduced new functionality for managing email attachments and drafts in the mail API.
- Added handlers for listing, uploading, and downloading message attachments in `internal/api/mail/handlers_attachments.go`.
- Implemented draft management endpoints for creating, updating, and deleting drafts in `internal/api/mail/handlers_drafts.go`.
- Created new service methods for handling draft and attachment operations in `internal/api/mail/drafts.go` and `internal/api/mail/storage.go`.
- Added validation and error handling for draft and attachment operations.
- Included unit tests for draft and folder functionalities in `internal/api/mail/drafts_test.go` and `internal/api/mail/folders_test.go`.
- Updated API routes to support new draft and attachment features, enhancing overall mail management capabilities.
2026-05-22 17:14:36 +02:00

46 lines
1.0 KiB
Go

package threading
import (
"reflect"
"testing"
)
func TestNormalizeMessageID(t *testing.T) {
tests := []struct {
in, want string
}{
{"", ""},
{"<a@b>", "<a@b>"},
{"a@b", "<a@b>"},
}
for _, tc := range tests {
if got := NormalizeMessageID(tc.in); got != tc.want {
t.Fatalf("NormalizeMessageID(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestParseMessageIDs(t *testing.T) {
got := ParseMessageIDs("<a@x> <b@y>")
want := []string{"<a@x>", "<b@y>"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("ParseMessageIDs() = %v, want %v", got, want)
}
}
func TestBuildReferences(t *testing.T) {
got := BuildReferences("<c@z>", []string{"<a@x>", "<b@y>"})
want := []string{"<a@x>", "<b@y>", "<c@z>"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("BuildReferences() = %v, want %v", got, want)
}
}
func TestBuildReferences_dedupesParent(t *testing.T) {
got := BuildReferences("<b@y>", []string{"<a@x>", "<b@y>"})
want := []string{"<a@x>", "<b@y>"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("BuildReferences() = %v, want %v", got, want)
}
}