优化结构
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package email
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"kra/internal/conf"
|
||||
)
|
||||
|
||||
func TestDefaultRecipientsIgnoreEmptyConfiguration(t *testing.T) {
|
||||
runtime := conf.NewRuntime(&conf.Data{}, &conf.AdminBackend{Email: &conf.AdminBackend_Email{To: " "}})
|
||||
repo := &emailRepo{runtime: runtime}
|
||||
if got := repo.DefaultRecipients(); len(got) != 0 {
|
||||
t.Fatalf("DefaultRecipients() = %#v, want empty", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendRejectsEmptyRecipientsBeforeNetworkDial(t *testing.T) {
|
||||
runtime := conf.NewRuntime(&conf.Data{}, &conf.AdminBackend{Email: &conf.AdminBackend_Email{Host: "smtp.example.com", From: "from@example.com", Secret: "secret", Port: 25}})
|
||||
repo := &emailRepo{runtime: runtime}
|
||||
if err := repo.Send(context.Background(), []string{" ", ""}, "subject", "body"); err == nil {
|
||||
t.Fatal("Send() accepted empty recipients")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user