package aws import ( "context" "testing" mailx "code.yun.ink/pkg/mailx" ) var _ mailx.Sender = (*Aws)(nil) func TestConfigDefaults(t *testing.T) { a := New(Config{}) if a.cfg.Region != "ap-northeast-1" { t.Errorf("default region = %q, want ap-northeast-1", a.cfg.Region) } // 显式指定 Region 时不应被覆盖 a = New(Config{Region: "us-east-1"}) if a.cfg.Region != "us-east-1" { t.Errorf("explicit region overwritten: %q", a.cfg.Region) } } func TestName(t *testing.T) { if got := New(Config{}).Name(); got != "aws" { t.Errorf("Name() = %q, want aws", got) } } func TestSendWithoutSender(t *testing.T) { // 缺少 Sender 时应立即报错,不创建 AWS 会话 a := New(Config{}) err := a.Send(context.Background(), mailx.NewMessage(). To("a@b.com"). Subject("s"). Build()) if err == nil { t.Fatal("Send without sender should error") } }