ultisuite-backend/internal/migration/gmail_import_test.go
R3D347HR4Y 7143a36c19
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
feat(mail): integrate Stalwart hosted mail and migration features
- Added configuration options for Stalwart hosted mail in .env.example.
- Updated Docker Compose to include Stalwart service with health checks.
- Introduced new API endpoints for managing mail domains and migration projects.
- Enhanced Authentik blueprints for user enrollment and post-migration security.
- Updated OAuth handling for Google and Microsoft migration processes.
- Improved error handling and response structures in the mail API.
- Added integration tests for email claiming and migration workflows.
2026-06-13 12:47:08 +02:00

58 lines
1.5 KiB
Go

package migration
import (
"encoding/json"
"testing"
)
func TestGmailUIDStable(t *testing.T) {
a := gmailUID("18c4f2a1b2d3e4f5")
b := gmailUID("18c4f2a1b2d3e4f5")
if a != b {
t.Fatalf("expected stable uid, got %d vs %d", a, b)
}
if a <= 0 {
t.Fatalf("expected positive uid, got %d", a)
}
}
func TestPrimaryGmailFolder(t *testing.T) {
remote, folderType := primaryGmailFolder([]string{"INBOX", "UNREAD"})
if remote != "INBOX" || folderType != "inbox" {
t.Fatalf("got %q / %q", remote, folderType)
}
remote, folderType = primaryGmailFolder([]string{"SENT"})
if remote != "SENT" || folderType != "sent" {
t.Fatalf("got %q / %q", remote, folderType)
}
remote, folderType = primaryGmailFolder([]string{"Label_123", "INBOX"})
if remote != "INBOX" || folderType != "inbox" {
t.Fatalf("inbox wins over label: got %q / %q", remote, folderType)
}
}
func TestParseAddressListJSON(t *testing.T) {
raw := parseAddressListJSON(`Alice <alice@example.com>, bob@example.com`)
var addrs []map[string]string
if err := json.Unmarshal(raw, &addrs); err != nil {
t.Fatal(err)
}
if len(addrs) != 2 {
t.Fatalf("expected 2 addresses, got %d", len(addrs))
}
if addrs[0]["email"] != "alice@example.com" {
t.Fatalf("unexpected first email: %v", addrs[0])
}
}
func TestDisplayFolderName(t *testing.T) {
if got := displayFolderName("Label_42", "custom"); got != "Label_42" {
t.Fatalf("custom label: %q", got)
}
if got := displayFolderName("INBOX", "inbox"); got != "Boîte de réception" {
t.Fatalf("inbox display: %q", got)
}
}