feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
54
internal/notify/email_test.go
Обычный файл
54
internal/notify/email_test.go
Обычный файл
@@ -0,0 +1,54 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
)
|
||||
|
||||
func TestEmail_NilCred(t *testing.T) {
|
||||
if err := Email(nil, "to@x.com", "s", "b", ""); err == nil {
|
||||
t.Fatal("expected error for nil cred")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmail_WrongKind(t *testing.T) {
|
||||
cred := &models.NotificationCredential{Kind: models.CredentialKindTelegram}
|
||||
if err := Email(cred, "to@x.com", "s", "b", ""); err == nil {
|
||||
t.Fatal("expected error for wrong kind")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmail_MissingRequiredFields(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
cred *models.NotificationCredential
|
||||
}{
|
||||
{"nil server", &models.NotificationCredential{Kind: models.CredentialKindSMTP}},
|
||||
{"nil port", &models.NotificationCredential{
|
||||
Kind: models.CredentialKindSMTP,
|
||||
Server: strPtr("smtp.x.com"),
|
||||
}},
|
||||
{"nil login", &models.NotificationCredential{
|
||||
Kind: models.CredentialKindSMTP,
|
||||
Server: strPtr("smtp.x.com"),
|
||||
Port: intPtr(587),
|
||||
}},
|
||||
{"nil fromaddr", &models.NotificationCredential{
|
||||
Kind: models.CredentialKindSMTP,
|
||||
Server: strPtr("smtp.x.com"),
|
||||
Port: intPtr(587),
|
||||
Login: strPtr("u"),
|
||||
}},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if err := Email(tc.cred, "to@x.com", "s", "b", ""); err == nil {
|
||||
t.Fatalf("expected error for %s", tc.name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func strPtr(s string) *string { return &s }
|
||||
func intPtr(i int) *int { return &i }
|
||||
Ссылка в новой задаче
Block a user