(t *testing.T)
| 567 | } |
| 568 | |
| 569 | func TestCreateOutboundMessage(t *testing.T) { |
| 570 | pool := testutil.TestDB(t) |
| 571 | store := identity.NewStore(pool) |
| 572 | ctx := context.Background() |
| 573 | |
| 574 | user, _ := store.CreateOrGetUser(ctx, "owner@example.com", "Owner", "google-outbound") |
| 575 | store.ClaimOrCreateDomain(ctx, "outbound.example.com", user.ID) |
| 576 | a, _ := store.CreateAgent(ctx, "agent@outbound.example.com", "outbound.example.com", "", "https://example.com/webhook", "", user.ID) |
| 577 | |
| 578 | msg, err := store.CreateOutboundMessage(ctx, a.ID, []string{"alice@gmail.com"}, nil, nil, "Re: Hello", "reply", "smtp", "", "", nil) |
| 579 | if err != nil { |
| 580 | t.Fatalf("CreateOutboundMessage: %v", err) |
| 581 | } |
| 582 | if msg.Direction != "outbound" { |
| 583 | t.Errorf("Direction = %q, want outbound", msg.Direction) |
| 584 | } |
| 585 | if msg.Method != "smtp" { |
| 586 | t.Errorf("Method = %q", msg.Method) |
| 587 | } |
| 588 | if msg.Type != "reply" { |
| 589 | t.Errorf("Type = %q", msg.Type) |
| 590 | } |
| 591 | if msg.Recipient != "alice@gmail.com" { |
| 592 | t.Errorf("Recipient = %q, want alice@gmail.com", msg.Recipient) |
| 593 | } |
| 594 | if len(msg.ToRecipients) != 1 || msg.ToRecipients[0] != "alice@gmail.com" { |
| 595 | t.Errorf("ToRecipients = %v, want [alice@gmail.com]", msg.ToRecipients) |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | func TestListActivityByAgent(t *testing.T) { |
| 600 | pool := testutil.TestDB(t) |
nothing calls this directly
no test coverage detected