Files
go-nkode/core/email_queue_test.go
2024-10-10 15:01:45 -05:00

30 lines
587 B
Go

package core
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestEmailQueue(t *testing.T) {
queue := NewEmailQueue(100, 14, &TestEmailClient{})
// Start the queue processing
queue.Start()
// Enqueue some emails
for i := 1; i <= 28; i++ {
email := Email{
Sender: "test@example.com",
Recipient: fmt.Sprintf("user%d@example.com", i),
Subject: "test subject",
Content: "This is a test email",
}
queue.AddEmail(email)
}
// CloseDb the queue after all emails are processed
queue.Stop()
assert.Equal(t, queue.FailedSendCount, 0)
}