(t *testing.T)
| 438 | } |
| 439 | |
| 440 | func TestBuildNotification(t *testing.T) { |
| 441 | now := time.Date(2026, 3, 27, 10, 0, 0, 0, time.UTC) |
| 442 | msg := &identity.Message{ |
| 443 | ID: "msg_bn", |
| 444 | Sender: "alice@example.com", |
| 445 | Recipient: "bot@agents.e2a.dev", |
| 446 | Subject: "Test Subject", |
| 447 | ConversationID: "conv_abc", |
| 448 | CreatedAt: now, |
| 449 | } |
| 450 | |
| 451 | data := BuildNotification(msg) |
| 452 | var notif map[string]interface{} |
| 453 | if err := json.Unmarshal(data, ¬if); err != nil { |
| 454 | t.Fatalf("unmarshal: %v", err) |
| 455 | } |
| 456 | |
| 457 | if notif["message_id"] != "msg_bn" { |
| 458 | t.Fatalf("expected msg_bn, got %v", notif["message_id"]) |
| 459 | } |
| 460 | if notif["conversation_id"] != "conv_abc" { |
| 461 | t.Fatalf("expected conv_abc, got %v", notif["conversation_id"]) |
| 462 | } |
| 463 | if notif["from"] != "alice@example.com" { |
| 464 | t.Fatalf("expected alice@example.com, got %v", notif["from"]) |
| 465 | } |
| 466 | if notif["recipient"] != "bot@agents.e2a.dev" { |
| 467 | t.Fatalf("expected bot@agents.e2a.dev, got %v", notif["recipient"]) |
| 468 | } |
| 469 | // Notification stays lightweight — full To/Cc lists are fetched via REST. |
| 470 | if _, hasTo := notif["to"]; hasTo { |
| 471 | t.Fatalf("notification should not include 'to'; clients fetch via REST") |
| 472 | } |
| 473 | if notif["subject"] != "Test Subject" { |
| 474 | t.Fatalf("expected Test Subject, got %v", notif["subject"]) |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | func TestBuildNotification_OmitsEmptyConversationID(t *testing.T) { |
| 479 | msg := &identity.Message{ |
nothing calls this directly
no test coverage detected